Write a program in C++ that computes the tax and tips on a restaurant bill for a
ID: 3786519 • Letter: W
Question
Write a program in C++ that computes the tax and tips on a restaurant bill for a patron with $88.67 meal cost. The tax is 6.75 percent of the meal cost. The tip is 20 percent of the total after the tax. Display the meal cost, tax amount, tip amount, and the total bill. Use constant: const double TAXRATE = 6.75 const double TIPRATE = 20.0 Use variables: mealCost - data type double tax - data type double billAfterTax - data type double tips - data type double totalBill - data type double Hints: The formula for calculation: Tax amount = Meal cost X Tax rate / 100 Bill after tax = Meal cost + Tax amount Tip amount = Bill after Tax X Tip rate / 100 Total bill = Bill after tax + Tip amount The output will be: (Your output should match the output as displayed below) - 2 points Meal cost = $ 88.67 Tax amount = $ 5.98 Tips amount = $ 18.93 (Blank Line in output) Total bill = $ 113.58 Do proper documentation in your program. The following remark lines be will placed at the top of your program. //Your Name //CSC 205-E1 //Assignment Name //Purpose: Assignment 1 – Restaurant Bill
Explanation / Answer
// C++ code
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <iomanip> // std::setprecision
using namespace std;
int main()
{
const double TAXRATE = 6.75;
const double TIPRATE = 20.0;
double mealCost = 88.67;
double tax;
double billAfterTax;
double tips;
double totalBill;
mealCost =88.67; // in dollars
tax = mealCost * TAXRATE / 100;
billAfterTax = mealCost + tax;
tips = billAfterTax *TIPRATE/100;
totalBill =billAfterTax +tips;
cout<<"Restaurant Bill";
cout<<" Meal Cost: $" << setprecision(4) <<mealCost;
cout<<" Tax amount: $" << setprecision(3) <<tax;
cout<<" Tips amount: $" << setprecision(4) <<tips;
cout<<" Total bill: $" << setprecision(5) <<totalBill << endl;
return 0;
}
/*
output:
Restaurant Bill
Meal Cost: $88.67
Tax amount: $5.99
Tips amount: $18.93
Total bill: $113.59
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.