Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lopputyö
- #include <iostream>
- using namespace std;
- int roomnumber;
- int amountofvisitors;
- int occupiedpl;
- int room;
- int totalvisitors;
- int totalcost = 0;
- char answer;
- const int maxrooms = 15;
- const int minrooms = 1;
- bool rooms[maxrooms];
- int main()
- {
- answer = 'y';
- for(int i=0; i<=maxrooms; i++){
- rooms[i] = false;
- }
- while (answer = 'y')
- {
- cout << "Rooms currenntly available\n";
- for(int i=0; i<maxrooms; i++){
- if(rooms[i] == false){
- cout << i << " ";
- }
- }
- int roomnumber = 0;
- cout << "\n\nWhich room would you like to book? ";
- cin >> roomnumber;
- while(roomnumber >= maxrooms || roomnumber < minrooms){
- cout << "Please enter a valid room number!\n";
- cout << "Which room would you like to book? ";
- cin >> roomnumber;
- }
- if(rooms[roomnumber] == true){
- cout << "This room is already booked! Would you like to try to book another room? (y/n) ";
- cin >> answer;
- }
- if(rooms[roomnumber] == false)
- {
- cout << "How many nights will you be staying?";
- cin >> amountofvisitors;
- totalvisitors = amountofvisitors;
- rooms[roomnumber] = true;
- occupiedpl++;
- cout << "Room " << roomnumber << " booked for " << amountofvisitors << ". Cost so far: ";
- totalcost += (totalvisitors * 100);
- cout << totalcost << "\n\n";
- cout << "Would you like to book another room? (y/n) ";
- cin >> answer;
- if(answer == 'n') break;
- }
- }
- cout << "Room booking is finished! Total cost: " << totalcost;
- system("PAUSE");
- return 0; }
Advertisement
Add Comment
Please, Sign In to add comment