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).

Solutions

Expert Solution

Since you have not mentioned the language of your preference, I am providing the code in Java.

CODE

#include <iostream>

using namespace std;

class Bill {

private:

double mealCharge;

double taxPercentage;

double tipPercentage;

public:

Bill(double mealCharge, double taxPercentage, double tipPercentage) {

this->mealCharge = mealCharge;

this->taxPercentage = taxPercentage;

this->tipPercentage = tipPercentage;

}

double getTaxAmount() {

return taxPercentage/100 * mealCharge;

}

double getTipAmount() {

return tipPercentage/100 * mealCharge;

}

double getMealCost() {

return mealCharge;

}

double getTotalCost() {

return getMealCost() + getTaxAmount() + getTipAmount();

}

};


int main() {

Bill bill(44.5, 6.75, 15);

cout << "Meal cost: $" << bill.getMealCost() << endl;

cout << "Tax amount: $" << bill.getTaxAmount() << endl;

cout << "Tip amount: $" << bill.getTipAmount() << endl;

cout << "Total cost: $" << bill.getTotalCost() << endl;

}

Problems Javadoc Declaration Search Consol <terminated> Main (2) [Java Application] /Library/Java/JavaVirtualMa Meal cost: $44.5 Tax amount: $3.00375 Tip amount: $6.675 Total cost: $54.178749999999994


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 using C++)
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 summary of the final tax bill
write a summary of the final tax bill
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,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT