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 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 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...
Write the Pseudocode for the following programming problem. Write a program that will calculate a tip...
Write the Pseudocode for the following programming problem. Write a program that will calculate a tip based on the meal price and a 6% 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. The tip amounts based on the mean price are as...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT