I am having trouble with double. The program seems to rounding when it feels like it depending on the input. Its probably something pretty simple but I thought "double" was to store decimal input. Can someone explain to me what is going on?
2 common issues:
1: output format. if you don't specify how many digits, you don't see the entire double. Be sure to output the double as much as you want to see of it using set precision and set width modifiers to cout. try
cout << std::setprecision(20) << variable << endl;
2: actual floating point representation. Some values cannot be stored exactly in floating point format, and you end up with like 7.999999999999999999999999999999999 instead of 8.0 even if you input 8.0. (this is a made up example, I don't memorize which values can't be stored). Or the reverse, you get 8.00000000000000000000001 instead of 8.0. This is normal expected behavior and its fine as long as you don't try to do == comparisons of values (zero is stored exactly, so == on zero is ok for special cases / checks).
also, consider just using pennies for money, using integer math.
In lines 5 - 7 you do not need the "f" at the end of your number. This is causing the number to be stored wrong. It is more like a float than a double.
After removing the "f" this is the output that is produced:
please enter the amount of milk produced:
The number of milk cartons needed is: 1323
The cost of producing the milk: 1900
the profit of producing the milk: 357.143
Press any key to continue . . .
Just a comment here, your output could use a little more information along with some blank lines. For "5000" is this gallons or liters or something else? In this case what is "1322.75"?