Could someone help me with this?

This is the warning message
http://s5.tinypic.com/28ilonq.jpg


Variables
http://s5.tinypic.com/n1a5fk.jpg

I know it should be an integer for the total_gal_paint, but it keeps giving me that message

Recommended Answers

All 2 Replies

Well, with how your code has plus 0.9999, you should leave total_gal_paint as a double. I assuming you want to chop off the decimals and round up if there are any decimals, hence the adding.

One way to get rid of the error is to leave total_gal_paint as a double but use setprecision(0) in front of the output so it would only show the integer part.

Another, if you want to store just the int is to have total_gal_paint be an int but write that line like this:

total_gal_paint = int( (total_area / coverage_gallon_paint) + (0.9999) );

That will convert it to an integer for you and should get rid of that error message.

This is called casting. The c++ style way to cast is

total_gal_paint = static_cast<int> ( (total_area / coverage_gallon_paint) + (0.9999) );

The code DemonGal711 posted is exactly the same thing as far as I know, its just a little "c style" :)

Also, it would be much easier if you posted the code using CODE tags rather than posting jpgs.

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.