how do i do the outputs to be in two decimal places. i tried setprecision but its not working. can you check what iam doing wrong please. its sales so our professor wants it to be like $9000.00
After you read the links that keskiverto suggested what I would try is to put this line after line 11. std::cout << std::fixed << std::showpoint << std::setprecision(2);. With time and experience I found that this line only needs to be done once and will affect every "cout" statement the follows until it is changes. You will find that "std::fixed" will use decimal numbers as opposed to "scientific notation". The "std::showpoint" will print the ".00" in an answer. and it looks like "std::setprecision(2)" you already have some understand of. All three parts will give you what you want.
Right now the "std::setprecision(2)" as you are using it deals with both the lhs and rhs of the decimal point plus the decimal point as I remember it.
While I am here "double"s are preferred over "float"s. The precision of a "double" is greater then a "float" and will store the number better, but not always correctly. This has more to do with how the computer stores the floating point number rather than the type of the variable.
On line 11 you should initialize all your variables. If your compiler is C++11 compliant you can simply us empty {}s and this will set the variable to in this case 0.0. Even though the function calls will give these variables a value in this case it is best not to have a garbage value for these variables.
Line 4 it is best not to use this line in a program. Some day this WILL get you in trouble. It may seem easy now, but you are missing the opportunity to learn what is in the standard name space while it is easy.