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 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.
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...
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.
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 program that prompts the user to enter a positive integer and then computes the...
Write a program that prompts the user to enter a positive integer and then computes the equivalent binary number and outputs it. The program should consist of 3 files. dec2bin.c that has function dec2bin() implementation to return char array corresponding to binary number. dec2bin.h header file that has function prototype for dec2bin() function dec2binconv.c file with main function that calls dec2bin and print results. This is what i have so far. Im doing this in unix. All the files compiled...
Write a program that reads in the radius and length of a cylinder and computes volume...
Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas: area = radius * radius * PI volume = area * length
Write a JavaScript program that computes the average of a collection of numbers and then outputs...
Write a JavaScript program that computes the average of a collection of numbers and then outputs the total number of values that are greater than the average. An A grade is any score that is at least 20% greater than the average. The B grade is any score that is not an A, but is at least 10% greater than the average. An F grade is any score that is at least 20% less than the average. The D grade...
Write a defining table and a computer program that computes and outputs the volume of a...
Write a defining table and a computer program that computes and outputs the volume of a torus with inner radius a and outer radius b. A doughnut is an example of a torus. Your program must read the inner radius and outer radius from two text fields and display the volume in a div. The formula for the volume of a torus is v =  π2(a + b)(a - b)2 4 where v is the volume, π is the constant pi,...
write a summary of the final tax bill
write a summary of the final tax bill
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