Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

17. Write a program that computes the tax and tip on a restaurant bill for a pat

ID: 3755502 • Letter: 1

Question

17. Write a program that computes the tax and tip on a restaurant bill for a patron with a $44.50 meal charge. The tax should be 6.75 percent of the meal cost, if the service was good (g) the tip should be 20 percent of the total after adding the tax, if the service was poor (p) the tip should be 158. Display the meal co total bill on the screen. Use at least one constant variable. (10 points) st, tax amount, tip amount, and the Include the following variables: subtotal, tax, tip, total variables you may need , and any other

Explanation / Answer

Below is the solution:

#include <iostream>
using namespace std;

int main()
{
double cost_of_meal = 44.50; //meal cost
double tax = 0.0675; //6.75% tax
double tip;
int subtotal;
int bill,total,Tip_TB;
char service;

//Calculate the tax of cost of meal
tax = cost_of_meal * tax;

//Calculate the amount of the bill
bill = tax + cost_of_meal;

cout<<"Please enter the service provided good(g), Poor(p): ";
cin>>service;
switch(service){ //switch case for service type
   case 'g':
       //Calculate the cost of the tip from bill
       Tip_TB = bill * .20; //20% tip if good service
       break;
   case 'p':
       //Calculate the cost of the tip from bill
       Tip_TB = bill * .15; //20% tip if good service
       break;
}

//Calculate the total amount of the bill plus tip
total = bill + Tip_TB;

//Display the results
cout << "The meal cost is: $" << cost_of_meal <<" without tax" << endl;
cout << "The tip amount is: $" << Tip_TB << endl;
cout << "The bill amount with tip is: $" << total << endl;
system("pause");
return 0;
}

Sample output:

Please enter the service provided good(g), Poor(p): p
The meal cost is: $44.5 without tax
The tip amount is: $7
The bill amount with tip is: $54


Please enter the service provided good(g), Poor(p): g
The meal cost is: $44.5 without tax
The tip amount is: $9
The bill amount with tip is: $56

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote