hi i need to display a floating point variable with two deciaml places. my problem is that when my answer is say 45.50 the zero does not show. how can i get the zero to show.
Code:#include <iostream.h> #include <iomanip.h> #include <math.h> int main() { float lenght, width, height, paintcost, gallonsneeded, area, cost; lenght = 20; height = 8; width = 12; paintcost = 22.75; area = 2*(lenght*height) + 2*(width*height) + (lenght*width); gallonsneeded = area/440; gallonsneeded = ceil(gallonsneeded); cost = gallonsneeded * 22.75; cout << " Gallons of paint needed will be " << gallonsneeded << endl; cout << " Total painting coast will be " << setprecision(4) << cost << endl; system("pause"); return 0; }



LinkBack URL
About LinkBacks


