Need Help with my assignment

Hello, I am writing a code to create a hotel bill, I am no stuck and it wont work. here is my assignment:


Write a program that calculates the bill for guests at a holte

a. Assume a group of guests are registering at once (like a wedding party).The program should start by asking the user how many individual reservations are there for the group (this should be a positive number from 1 - 100).

b. A loop should be used to iterate once for each reservation. In each iteration, the loop should ask the user:

the desired floor; a number from 2 - 12 (floor 1 is the lobby) - If an incorrect floor is entered keep asking for the user to re-enter till a number from 2 - 12 is entered.
if they want a double, queen, or suite type of room (use d, q, or s)
the number of day they are staying - for 4 or more days include a 10% discount on the daily rate
if they are part of a special event like a wedding or conference - include a 40% discount on the daily rate

c. After all of the replies to the four questions are answered for the first guest, the program should calculate the bill based on the table of information below and the appropriate discounts for 4 or more days and a special event. If the customer is in both a special event and staying 4 or more days; take the sepcial event discount first and then the 10% discount for the extended stay.

d. The bill should be displayed - showing all of the discounts and repeating the information entered.
Floor # Double Queen Suite
2 - 5 150 200 242
6 - 10 170 220 260
11 - 12 200 250 280



d. Then return to the top of the loop and advance to the next registration in the group.



YOU CAN NOT USE AN EXIT OR GO TO STATEMENT - YOU NEED TO DEVELOP THE CORRECT DECISION AND LOOP STATEMENTS.

here is the code I have so far:

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  #include <iostream>
#include<conio.h>
using namespace std;

int main() {
   int room,floorNum,nights,guests;
   double price=0.0;
cout << "How many people are you checking in? ";

cin >> guests;

	cout << endl;

	
	cout << "Please enter what type of room you woud like (D for Double, Q for queen, S for a Suite): ";
	cin >> room;
	cout << endl;
	
	 if (room == 'D' || room == 'd' || room == 'S' || room== 's' || room == 'Q' || room == 'q'){
		  
		  cin >> room; 
		  cout << endl;
		}
	 else 
	    {
		  cout << "Invalid room choice, please select another: "; 
		  cin >> room;
		  cout << endl; 
	    }
	getche();

	cout << "Please enter what floor you want to stay on m (2 - 12): ";
	cin >> floorNum;
	cout << endl;
	 if (floorNum > 1 || floorNum <13)
		{
		  cin >> floorNum; 
		  cout << endl;
		}
	 else 
	    {
		  cout << "Invalid floor, please choose another: "; 
		  cin >> floorNum;
		  cout << endl; 
	    }

	getche();
	cout << "How many nights do you wish to stay? ";
	cin >> nights;
	cout << endl;

	getche();
  
   switch(room) {
    case 'D':
    {
       if(floorNum >= 2 && floorNum <= 5) {
          price = 150.00;
       }
       else if (floorNum >= 6 && floorNum <= 10) {
          price = 170.00;
		 }
		 else if (floorNum >= 11 && floorNum <= 12) {
          price = 200.00;
       }
       if(price > 0.00 && nights >= 4) {
          price -= (price * .10);
       }    
	 }
    break;
  
	 case 'Q':
    {
        
        if(floorNum >= 2 && floorNum <= 5) {
          
            price = 200.00;
        }
        else if (floorNum >= 6 && floorNum <= 10) {
           
            price = 220.00;
		}
		else if (floorNum >= 11 && floorNum <= 12) {
          
            price = 250.00;
        }
        if(price > 0.00 && nights >= 4) {
            price -= (price * .10);
        }    
	}
    break;

	case 'S':
    {
        if(floorNum >= 2 && floorNum <= 5) {
          
            price = 242.00;
        }
        else if (floorNum >= 6 && floorNum <= 10) {
           
            price = 260.00;
		}
		else if (floorNum >= 11 && floorNum <= 12) {
          
            price = 280.00;
        }
        if(price > 0.00 && nights >= 4) {
            price -= (price * .10);
        }    
	}
    break;
	}
	
   
  
   
   
   getche();	

   return 0;
}



The code does kind of run, but ends when you pick which floor. any and all help is appreciated, thanks!
line 6: room is declared int but,
line 19: comparing room to char
line 21: why are you asking for room again if it is correct? What do you really want to do here?
line 30: I am not sure what getche() does or why you need it.
line 37: The same problem as line 21.
lines 54 to 112: switch statement - may be easier to understand and implement if you place switch statements for room inside your if statements because it looks you are repeating the if statements over and over.

Your indentation is all over the place and hard to read.
Last edited on
Topic archived. No new replies allowed.