Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get numbers in my ouput to display less place holders?
    primarykey
    data
    text
    <p>I am very much a beginner programmer, finishing up Chapter 2 in Starting out with C++ (e7) by Tony Gladdis. I am doing my best to teach myself. Currently I am working on the Challenges at the end of the chapter. The problem I am having is how my output is displaying. With my current code, my output displays my numbers as 54.6293, when I just want it to display 54.62. Can someone please tell me how I can specify in my code to create my desired output?</p> <p>/* Write a program that computes the tax and tip on a restraunt bill for a patron with a $44.50 meal charge. The tax should be 6.75 percent of the meal cost. The tip should be 15 percent of the total after adding the tax. Display the meal cost, tax amount, tip amount, and total bill on the screen*/</p> <pre><code> #include &lt;iostream&gt; using namespace std; int main() { double Meal_Cost = 44.50, Total_After_Tax, Tax_Amount, Total_Bill, Total_Tip; const double TIP = 0.15, MEAL_TAX = 0.0675; // Calculate Tax_Amount Tax_Amount = Meal_Cost * MEAL_TAX; // Calculate Total_After_Tax Total_After_Tax = Tax_Amount + Meal_Cost; // Calculate Total_Tip Total_Tip = Total_After_Tax * TIP; // Calculate Total_Bill Total_Bill = Total_After_Tax + Total_Tip; // Display results cout &lt;&lt; "The meal cost " &lt;&lt; Meal_Cost &lt;&lt; " dollars." &lt;&lt; endl; cout &lt;&lt; "The tax applied to the meal purchase was " &lt;&lt; Tax_Amount &lt;&lt; " dollars." &lt;&lt; endl; cout &lt;&lt; "The tip amount for the purchase was " &lt;&lt; Total_Tip &lt;&lt; " dollars." &lt;&lt; endl; cout &lt;&lt; "The total bill came to " &lt;&lt; Total_Bill &lt;&lt; " dollars." &lt;&lt; endl; system ("PAUSE"); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload