what did I do wrong?

June 21, 2018 at 19:27:57
Specs: Windows 10
so I am supposed to make a bill calculator for c++ visual studio that calculates and prints totals, tax amt,,,etc It runs but i cannot get it to calculate and print calculations after your prompted. Please tell me what is wrong i know it has to be something easy.

#include <iostream>
#include <string>
using namespace std;

int main()
{
double bill, tax_rate, tip_percent, tax_amt, tip_amt, total;

cout << "Moonglo Restaurant" << endl << endl;

cout << "Bill Calculator " << endl << endl;

cout << "Enter bill amount : $ ";
cin >> bill;
cout << "Enter tip percentage: ";
cin >> tip_percent;
cout << "You entered the following :\n" << endl;

cout << "Bill Amount :" << bill << endl;
cout << "Tip :" << tip_percent << endl;


tax_rate = 100 / 0.09;
tax_amt = bill * tax_rate / 100;
total = bill + tax_amt;
tip_amt = total * tip_percent / 100;
total = total + tip_amt;

cout << "\n\nBill: $" << bill << endl;

cout << "Tip rate: " << tip_percent << "%" << endl;
cout << "Tip: $" << tip_amt << endl;
cout << "Tax: $" << tax_amt << endl;
cout << "Total: $" << total << endl;
return 0;
}

message edited by Lost_Girl


See More: what did I do wrong?

Reply ↓  Report •

#1
June 22, 2018 at 05:13:24
inb4 Mechanix2Go or Razor2.3 answers this correctly

also im getting this as a result
with:
bill= 23
tip% = 5

Bill: $23
Tip rate: 5%
Tip: $13.9278
Tax: $255.556
Total: $292.483


...Program finished with exit code 0
Press ENTER to exit console.

i changed this:

tax_rate = 100 / 0.09;

to

tax_rate = 100 * 0.09;

now i get:

Bill: $23
Tip rate: 5%
Tip: $1.2535
Tax: $2.07
Total: $26.3235

edit: using this online compiler:
https://www.onlinegdb.com/online_c+...

i5-6600K[delid]@4.8GHz/4.4GHz@1.39v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-13-13-28 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1430Mhz core@1.256v/1920MHz BiosModded

message edited by hidde663


Reply ↓  Report •

#2
June 22, 2018 at 06:21:29

Reply ↓  Report •
Related Solutions


Ask Question