Question

In: Computer Science

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

Write a program that computes the tax and tip on a restaurant bill for a patron with $44.50 meal charge. The tax should be 6.75% of the meal cost. The tip should be 15% of the total after adding tax. Display the meal cost, tax amount, tip amount, and total bill on the screen. (I need this to be in OOP using C++)

Solutions

Expert Solution

#include <iostream>
using namespace std;

class Bill
{
private:
double mealCharge;
double tax;
double tip;

public:
Bill(double mealCharge,double tax)
{
   this->mealCharge = mealCharge;
   this->tax = tax;
}
double calculateTip()
{
   return (mealCharge + mealCharge*tax)*0.15;
}
void displayBill()
{
   cout<<"Meal Cost : $"<<mealCharge<<endl;
   cout<<"Tax : $"<<tax*mealCharge<<endl;
   cout<<"Tip : $"<<calculateTip()<<endl;
   cout<<"Total Bill : $"<<(mealCharge +tax*mealCharge+ calculateTip());
  
}
};

int main() {
  
   Bill b(44.5,0.0675);
   b.displayBill();
  
  
   return 0;
}

Output:

Meal Cost : $44.5
Tax : $3.00375
Tip : $7.12556
Total Bill : $54.6

Do ask if any doubt. Please upvote.


Related Solutions

Write a program that computes the tax and tip on a restaurant bill for a patron...
Write a program that computes the tax and tip on a restaurant bill for a patron with $44.50 meal charge. The tax should be 6.75% of the meal cost. The tip should be 15% of the total after adding tax. Display the meal cost, tax amount, tip amount, and total bill on the screen. (I need this to be in OOP).
Write a program that will calculate a 15% tip and a 13% tax on a meal...
Write a program that will calculate a 15% tip and a 13% tax on a meal price. The user will enter the meal price and the program will calculate tip, tax, and the total. The total is the meal price plus the tip plus the tax. Your program will then display the values of tip, tax, and total. Please format the output, also the round up to 2 decimal places. Write the code in python.
Write a Python program that computes the income tax for an individual. The program should ask...
Write a Python program that computes the income tax for an individual. The program should ask the user to enter the total taxable income for the year. The program then uses the tax bracket (as shown below) to calculate the tax amount. This is based on a progressive income tax system which is how income tax is calculated in the U.S. As a result, this for example means that only income above $500,001 is taxed at 37%. Income of lower...
Write a Python program that computes the income tax for an individual. The program should ask...
Write a Python program that computes the income tax for an individual. The program should ask the user to enter the total taxable income for the year. The program then uses the tax bracket (as shown below) to calculate the tax amount. This is based on a progressive income tax system which is how income tax is calculated in the U.S. As a result, this for example means that only income above $500,001 is taxed at 37%. Income of lower...
Business students want to predict the average customer tip from an average customer’s restaurant bill. They...
Business students want to predict the average customer tip from an average customer’s restaurant bill. They have collected data from five customers. The results are listed below: Customer Bill Tip 1 78 14.50 2 33 5.50 3 64 12 4 55 10.5 5 115 22 Develop a regression model to predict the tip amount based on the customer bill amount. B. Calculate the predicted tip (Y value), if x=82.
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
Question: Rewrite the program in C which computes the tax due based on a tax table....
Question: Rewrite the program in C which computes the tax due based on a tax table. Instead of using the if/else structure, use the switch statement. /* Pre : salary is predefined *Post: Returns the tax due for 0.0 <= salary <= 150,000.00; returns -1.0 if salary is outside of table range. */ double comp_tax(double salary) { double tax; if (salary < 0.0) tax = -1.0; else if (salary < 15000.00) tax = 0.15 * salary; else if (salary <...
write a summary of the final tax bill
write a summary of the final tax bill
Write the following java program. Desc: The program computes the cost of parking a car in...
Write the following java program. Desc: The program computes the cost of parking a car in a public garage at the rate $5.00/hour. The client will always be charged for whole hours. For example, if a car parked for 2 hours and 1 minute, the client will be charged for 3 hours. Input: User inputs the entry time and exit time in 24-hr clock format (hh:mm) Output: The enter and exit times, the length of time the car is parked...
Customer Amount of Tip Amount of Bill Number of Diners Customer Amount of Tip Amount of...
Customer Amount of Tip Amount of Bill Number of Diners Customer Amount of Tip Amount of Bill Number of Diners 1 $ 7.70 $ 46.02 1 16 $ 3.30 $ 23.59 2 2 4.50 28.23 4 17 3.50 22.30 2 3 1.00 10.65 1 18 3.25 32.00 2 4 2.40 19.82 3 19 5.40 50.02 4 5 5.00 28.62 3 20 2.25 17.60 3 6 4.25 24.83 2 21 3.90 58.18 1 7 0.50 6.25 1 22 3.00 20.27 2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT