Hello everyone I am working on my first C++ program ahead of schedule and I think I almost have it down. The only thing that has me scratching my head is that the tax keeps coming out to 8 dollars instead of 8.25. Thank you all for your time and input =)
This is the goal I am looking to get as my output:
Test case‐1:
Program input:
> Enter meal cost (in $): 100.00
>Enter tax (in percentage): 8.25
> Enter tip (in percentage): 15
Program output:
Bill summary:
===========
Meal cost: $100.00
Tax amount: $8.25
Tip amount: $15.00
Total bill: $123.25
This is my code so far and everything is working accept the tax amount which of course messes up my total bill by .25 cents.
#include <iostream>
usingnamespace std;
int main()
{
double meal_cost = 100.00,
tax = 0.0825,
tip = .15;
int Tax_MC,
bill,
total_bill,
Tip_TB;
cout << "What is the meal cost?:";
cin >> meal_cost;
cout << "What is the tax amount in percent?:";
cin >> tax;
cout << "What is the tip amount in percent?:";
cin >> tip;
//Formula for the tax of the meal cost.
Tax_MC = mealCost * tax;
//Formula for the amount of the bill.
bill = mealCost * tip;
//Forumula for the cost of the tip from the bill.
Tip_TB = mealCost + taxTotal + tipTotal;
//Formula for total amount of the bill plus tip.
//Display the results
cout << "Bill summary" << endl;
cout << "============" << endl;
cout << "The meal cost came up to $" << meal_cost << endl;
cout << "The tax amount of the meal cost is $" << Tax_MC << endl;
cout << "The tip came up to $" << Tip_TB << endl;
cout << "The total amount of the bill is $" << total_bill << endl;
system("pause");
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
double meal_cost = 100.00,
tax = 0.0825*meal_cost,
tip = .15,
Tax_MC,
total_bill,
Tip_TB;
//Input for the meal cost.
cout << "What is the meal cost?:";
cin >> meal_cost;
//Input for tax amount in percent.
cout << "What is the tax amount in percent?:";
cin >> tax;
//Input for tip amount in percent.
cout << "What is the tip amount in percent?:";
cin >> tip;
//Formula for the tax of the meal cost.
Tax_MC = meal_cost * tax;
//Forumula for the cost of the tip from the bill.
Tip_TB = meal_cost * tip;
//Formula for total amount of the bill plus tip.
total_bill = meal_cost + Tax_MC + Tip_TB;
//Display the results
cout << "Bill summary" << endl;
cout << "============" << endl;
cout << "The meal cost came up to $" << meal_cost << endl;
cout << "The tax amount of the meal cost is $" << Tax_MC << endl;
cout << "The tip came up to $" << Tip_TB << endl;
cout << "The total amount of the bill is $" << total_bill << endl;
system("pause");
return 0;
}