This is the program instructions: Enter meal cost: Enter tax (in percentage): En
ID: 3628366 • Letter: T
Question
This is the program instructions:Enter meal cost:
Enter tax (in percentage):
Enter tip (in percentage):
Display bill summary:
Meal Cost
Tax amount
Tip amount
Total bill
This is what I came up with:
#include <iostream>
using namespace std;
int main()
{
double mealCost,
taxAmount,
tipAmount,
roundAmount, subTotal, finalAmount, totalBill;
cout << "Enter the meal cost" << endl;
cin >> mealCost;
cout << "Enter the tax amount" << endl;
cin >> taxAmount;
cout << "Enter the tip amount" << endl;
cin >> tipAmount;
//Calculate meal cost with 8.25% tax amount.
roundAmount = mealCost * taxAmount;
//Calulate the subtotal with the round amount and meal cost.
subTotal = mealCost + roundAmount;
finalAmount = subTotal * tipAmount;
//Calculate the total bill with sum total and tip amount.
totalBill = subTotal + finalAmount;
//Display the bill summary.
cout << "The meal cost is" << mealCost << endl;
cout << "The tax amount is" << taxAmount << endl;
cout << " The tip amount is" << tipAmount << endl;
cout << "The total bill is" << totalBill << endl;
return 0; (error is shown here).
}
When I run this program...the error reads...this character is not allowed in an identifier...
Explanation / Answer
// program is perfect.
// compile and run online at
// http://www.ideone.com/8vwMF
#include <iostream>
using namespace std;
int main()
{
double mealCost,
taxAmount,
tipAmount,
roundAmount, subTotal, finalAmount, totalBill;
cout << "Enter the meal cost" << endl;
cin >> mealCost;
cout << "Enter the tax amount" << endl;
cin >> taxAmount;
cout << "Enter the tip amount" << endl;
cin >> tipAmount;
//Calculate meal cost with 8.25% tax amount.
roundAmount = mealCost * taxAmount;
//Calulate the subtotal with the round amount and meal cost.
subTotal = mealCost + roundAmount;
finalAmount = subTotal * tipAmount;
//Calculate the total bill with sum total and tip amount.
totalBill = subTotal + finalAmount;
//Display the bill summary.
cout << "The meal cost is" << mealCost << endl;
cout << "The tax amount is" << taxAmount << endl;
cout << " The tip amount is" << tipAmount << endl;
cout << "The total bill is" << totalBill << endl;
return 0; // (no error here).
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.