-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCooperFeatherstoneHW3.cpp
72 lines (61 loc) · 2.23 KB
/
CooperFeatherstoneHW3.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//defining the variables
double costPerRoom;
int numOfRoom;
int numOfNights;
float salesTax;
double netPrice;
double total;
double taxAmmount;
int main() {
//fixing the decimal point
cout<<fixed<< showpoint<< setprecision(2);
//prompting the user to enter values for the variables
cout<< "Enter the cost of renting one room: ";
cin>> costPerRoom;
cout<< "Enter the number of rooms booked: ";
cin>> numOfRoom;
cout<< "Enter the number of nights the rooms are booked: ";
cin>> numOfNights;
cout<< "Enter the sales tax (as a percent): ";
cin>> salesTax;
cout<< endl;
//adding up the price
netPrice= costPerRoom * numOfRoom * numOfNights;
//giving the discounts
if(numOfRoom >= 10 && numOfRoom < 20){
netPrice = netPrice * .9; //10% discount
}
if(numOfRoom >= 20 && numOfRoom < 30){
netPrice = netPrice * .8; //20% discount
}
if(numOfRoom >= 30){
netPrice = netPrice * .7; //30% discount
}
if(numOfNights >= 3){
netPrice = netPrice * .95; //5% discount
}
//calculate the tax amount
taxAmmount = netPrice * (salesTax / 100);
//calculate the total amount
total = taxAmmount + netPrice;
//print everything out
cout<< "Thank you for shopping at IgniteMart" << endl;
cout<< "------------------------------------" << endl;
cout<< left << setw(45) << "The cost of renting one room:"
<< right << setw(1) << "$ " << costPerRoom << endl;
cout<< left << setw(45) << "The total number of rooms booked:"
<< right << setw(1) << " " << numOfRoom << " rooms" << endl;
cout<< left << setw(45) << "The number of nights the rooms are booked:"
<< right << setw(1) << " " << numOfNights << " nights" << endl;
cout<< left << setw(45) << "The total cost of the rooms:"
<< right << setw(1) << "$ " << netPrice << endl;
cout<< left << setw(45) << "The sales tax amount:"
<< right << setw(1) << "$ " << taxAmmount << endl;
cout<< left << setw(45) << "The total:"
<< right << setw(1) << "$ " << total << endl;
return 0;
}