### hi i'm new to C++ how to make setprecision work for how numbers

how to make fixed and setprecision show for all my numbers
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` `````` { const double PRIX_FIXE = 50, SALES_TAX_RATE = .0825, TIP_PERCENTAGE = .15; double meals_ordered = 0; int total_meals, tax, tips, total_due; cout << "Enter the number of Prix Fixe Meals:" ; cin >> meals_ordered; cout << "\n"; cout << "Author's Shawn,King\n" << "C.S.1428. 3\n" <<"Due Date 09/18/13\n\n"; total_meals = PRIX_FIXE * meals_ordered; tax = total_meals * SALES_TAX_RATE; tips = (total_meals + tax) * TIP_PERCENTAGE; total_due = total_meals + tax + tips; cout << fixed << setprecision(2); cout <<"Prix Fixe Price: \$ " << setw(9) << PRIX_FIXE <<"\n"; cout << setw(23)<< "x " << setw(9) << meals_ordered <<"\n\n"; cout <<"Total for # of meals: " << setw(4) << total_meals <<"\n"; cout <<"Sales Taxs @8.25% " << setw(7) << tax <<"\n"; cout << "15% Tips: " << setw(16) << tips <<"\n" <<"Total Due: \$ " << setw(7) << total_due; return 0; }``````
Last edited on
> how to make fixed and setprecision show for all my numbers

`std::fixed` and `std::setprecision()` specify formatting for floating point numbers.

Make the following change:

 ``123456`` ``````/* double */ int meals_ordered = 0; /* int */ double total_meals, tax, tips, total_due;``````

thanks that worked
Topic archived. No new replies allowed.