Hello, I have the program that I am trying to write in the comments directly
below. My issue is when the program runs, I am getting answers completely incorrect. So I will get:
Meal Cost is $88.76 <--- This one is fine
Tax amount is $5.99 <---- This one is fine
Tip amount is $137.44
Total bill is $232.09
I thought it was something in my equations causing these problems but it does not seem to be so when I do the equations by hand. Any idea where I've gone wrong here would be great. Thank you.
// Restaurant Bill Write a program that computes the tax and tip on a restaurant bill for a patron with a
// $88.67 meal charge. The tax should be 6.75 percent of the meal cost. The tip should be 20 percent of the total
// after adding the tax. Display the meal cost, tax amount, tip amount, and total bill on the screen.
#include "pch.h"
#include <iostream>
#include <iomanip>
using namespace std;
Why not just have your meal in its actual value instead of doing this * 100 thing?
i.e. double mealCharge = 88.67;
That would prevent you from ever having to do * 100 in your code.
* 100 is only needed for displaying percentages in ways that pesky humans like them (0.02 --> 20%).
This is what's causing your problem.
First:
Your tax percent is 6.75%
6.75% of $88.67 is $5.985225, which is 0.05985 in your program, not 0.5985. Your comment is off by a factor of 10.
Second:
When you do (mealCharge + taxAmount), your taxAmount is in real units ($5.9 bucks), but your mealCharge is in your "divided by 100" units.
Multiply mealCharge by 100, but not the overall result