2. Sy residences owns 5 condominium units which is located to different cities in the Philippines. The units are used to accommodate travelers from all over the world. Each unit has a base price of 3,000 per night. Units are good for 4 persons only, however the guest can pay an extra charge of 500 per person in excess. Children below 4 years old are free. Guests will be given 10% discount for more than a week of stay. 15% for more than 15 days and 20% for a month. Write a program that will ask the user to enter the number of days that the guest will stay, total number of guests that will check in, number of children below 4 years old and display the total amount that the user will pay. Sample Output Welcome to Sy Residences! Please enter the number of days that you will stay: 5 Number of Guests: 5 Number of children below 4 years old: 0 Total Amount that the guest will pay: 17500

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Below is my C++ code. Can I make it shorter?

 

#include <iostream>

 

using namespace std;

 

int main()

{

  int days, guests, children_below_4;

  float total;

 

  cout<< "Welcome to Sy Residences! \n";

 

  cout<< "Please enter the number of days that you will stay: ";

  cin>>days;

 

 

cout<< "Number of Guests: ";

  cin>>guests;

 

cout<< "Number of children below 4 years old: ";

  cin>>children_below_4;

 

 

  total = (3000*days);

 

  if (guests <=4) {

 

                total = total;

                cout<< "Total amount that the guest will pay: " <<total;

}

  else {

                total = total + (days)*(500)*(guests - children_below_4 - 4);

                cout<< "Total amount that the guest will pay: " <<total;

 

  if (days <= 7) {

                total = total;

                cout<< "Total amount that the guest will pay: " <<total;

 

}

  else if (days >= 30){

                total = (total)*(0.80);

                cout<< "Total amount that the guest will pay: " <<total;

 

}

  else {

               

switch(days)

{

case 8:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

   

case 9:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

   

case 10:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

 

case 11:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

case 12:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 13:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 14:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 15:

                total= (total)*(0.90);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 16:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 17:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 18:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 19:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

               

case 20:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 21:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 22:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

 

case 23:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

               

case 24:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

                break;

               

case 25:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

 

case 26:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

 

case 27:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

   

case 28:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

 

case 29:

                total= (total)*(0.85);

                cout<< "Total amount that the guest will pay: " <<total;

    break;

   

default:

    cout<<"Your input is invalid.";

 

}

}

  return 0;

 

}

 

2. Sy residences owns 5 condominium units which is located to different cities in the Philippines.
The units are used to accommodate travelers from all over the world. Each unit has a base price
of 3,000 per night. Units are good for 4 persons only, however the guest can pay an extra
charge of 500 per person in excess. Children below 4 years old are free. Guests will be given 10%
discount for more than a week of stay. 15% for more than 15 days and 20% for a month. Write
a program that will ask the user to enter the number of days that the guest will stay, total
number of guests that will check in, number of children below 4 years old and display the total
amount that the user will pay.
Sample Output
Welcome to Sy Residences!
Please enter the number of days that you will stay: 5
Number of Guests: 5
Number of children below 4 years old: 0
Total Amount that the guest will pay: 17500
Transcribed Image Text:2. Sy residences owns 5 condominium units which is located to different cities in the Philippines. The units are used to accommodate travelers from all over the world. Each unit has a base price of 3,000 per night. Units are good for 4 persons only, however the guest can pay an extra charge of 500 per person in excess. Children below 4 years old are free. Guests will be given 10% discount for more than a week of stay. 15% for more than 15 days and 20% for a month. Write a program that will ask the user to enter the number of days that the guest will stay, total number of guests that will check in, number of children below 4 years old and display the total amount that the user will pay. Sample Output Welcome to Sy Residences! Please enter the number of days that you will stay: 5 Number of Guests: 5 Number of children below 4 years old: 0 Total Amount that the guest will pay: 17500
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY