Aug 30, 2012 at 1:51am UTC
I'm new to c++ and I wrote a program that computes the tax and the tip on a restaurant bill for 2 patrons. The tax was fixed at 6.75 percent of the mean charge. John wants to pay 15% tip and shelly wants to pay 20% tip. I'm a little confused about the calculations. What did I do wrong how do I fix it.
//Restaurant Bill
//Write a program that computes the tax and the tip on a restaurant bill for 2 patrons: John and Shelly.
#include <iostream>
using namespace std;
int main()
{
double john_mealcharge,shelly_mealcharge, john_tax, shelly_tax, john_tip, shelly_tip;
double johntotal, shellytotal;
cout << "Please enter John's meal charge " << endl;
cin >> john_mealcharge;
cout << "Please enter Shelly's meal charge " << endl;
cin >> shelly_mealcharge;
cout << "Please enter John's tax " << endl;
cin >> john_tax;
cout << "Please enter Shelly's tax " << endl;
cin >> shelly_tax;
cout << "Please enter John's tip " << endl;
cin >> john_tip;
cout << "Please enter Shelly's tip " << endl;
cin >> shelly_tip;
johntotal = john_mealcharge + john_tax*6.75 + john_tip*.15;
shellytotal = shelly_mealcharge + shelly_tax*6.75 + shelly_tip*.20;
cout << "John's total restaurant bill is " << johntotal << ",and Shelly's is " << shellytotal << endl;
system("pause>nul");
return 0;
Last edited on Aug 30, 2012 at 2:47am UTC
Aug 30, 2012 at 2:08am UTC
I think no need to get tax input from the user because it is fixed as 6.75% with meal charge.
So
johntotal=john_mealcharge+(johnmealcharge*0.0675)+john_tip;
shellytotal=shelly_mealcharge+(shellymealcharge*0.0675)+shelly_tip;
May I know why u multiply tips with .15 and .20?
Aug 30, 2012 at 2:14am UTC
Thank you for the help but sorry I forgot to add that John wants to pay 15% tip and shelly wants to pay 20% tip thats why I multiplied by .15 and .20
Aug 30, 2012 at 3:05am UTC
Your welcome. Im also beginner in C++.