I'm stuck please help
Jan 31, 2016 at 2:35am UTC
Hi, this is an assignment for an intro to C++ class. When I run the program the totals for the Itemized bill should equal Total Room Charge = $600, Total Resort Fee $60, Total Resort Tax = $56.1, Total Bill = $716.1, Total Deposit = $66, and Amount due at arrival = $650.1
for me all the calculations come out right except Total Bill which i get $660, and Amount due $594. I figure that I'm not adding 56.1 into line 17 but when I do it gives me an error Does anyone one have any suggestions on why this isn't working. Also I was told not to hard code just use the variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include <iostream>
using namespace std;
int main()
{
double roomCharge, TOTAL_RESORT_FEE, totalCharges, resortTax;
double deposit, arrival;
roomCharge = 6 * 100;
TOTAL_RESORT_FEE = 10 * 6;
totalCharges = roomCharge + TOTAL_RESORT_FEE;
resortTax =.085 * totalCharges ;
deposit = (totalCharges) * .10;
arrival = totalCharges - deposit ;
cout << "\nLength of stay = 6 days" ;
cout << "\nDaily rate = $100" ;
cout << "\nDaily Resort Fee = $10" ;
cout << "\nResort Tax Rate = .085 " ;
cout << "\nItemized Bill:" ;
cout << "\nTotal Room Charge = $" << roomCharge;
cout << "\nTotal Resort Fee = $" << TOTAL_RESORT_FEE;
cout << "\nTotal Resort Tax = " << resortTax;
cout << "\nTotal Bill = $" << totalCharges;
cout << "\nTotal deposit = $" << deposit;
cout << "\nAmount due at arrival = $" << arrival;
cout << endl << endl;
system("pause" );
return 0;
}
Jan 31, 2016 at 3:08am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <iostream>
int main()
{
const int ndays = 6 ;
const double room_rate = 100.0 ;
const double resort_rate = 10.0 ;
const double tax_rate = 0.085 ;
const double deposit_fraction = 0.10 ;
const double room_charge = ndays * room_rate ;
const double total_resort_fee = ndays * resort_rate ;
double total_charges = room_charge + total_resort_fee;
const double deposit = total_charges * deposit_fraction ;
const double resort_tax = tax_rate * total_charges ;
total_charges += resort_tax ; // *** add tax to total charges ***
const double due_at_arrival = total_charges - deposit ;
std::cout << "\nLength of stay = " << ndays << " days"
<< "\nDaily rate = $" << room_rate
<< "\nDaily Resort Fee = $" << resort_rate
<< "\nResort Tax Rate = " << tax_rate << '\n' ;
std::cout << "\nItemized Bill:"
<< "\nTotal Room Charge = $" << room_charge
<< "\nTotal Resort Fee = $" << total_resort_fee
<< "\nTotal Resort Tax = " << resort_tax
<< "\nTotal Bill = $" << total_charges
<< "\nTotal deposit = $" << deposit
<< "\nAmount due at arrival = $" << due_at_arrival << '\n' ;
}
Jan 31, 2016 at 5:06am UTC
Thank you.
Topic archived. No new replies allowed.