10.7k views
3 votes
You are writing a program to check people into a hotel. People over 65 get a 10% discount. How would you write the program?

1 Answer

2 votes

Final answer:

To write a hotel check-in program that gives a discount to guests over 65, you need to input the guest's age, apply a conditional check for the age, calculate a 10% discount if applicable, and then output the final room rate.

Step-by-step explanation:

To write a program that checks people into a hotel and applies a 10% discount for people over 65 years old, you would need to include a few key elements. First, you would need to accept the guest's age as input. Then, you would apply a conditional statement to check if the age is greater than 65. If the condition is true, you calculate the discounted price by applying the 10% discount to the standard room rate. Finally, you would output the final room rate for the guest, which would be either the discounted rate or the standard rate.

Example pseudocode:

  • Input age
  • If age > 65 then
  • Calculate discount (10% of standard room rate)
  • Apply discount to the standard room rate
  • End if
  • Output final room rate

This example demonstrates how to apply a conditional discount based on the guest's age in a hotel check-in system.

User Rahul Galgali
by
8.3k points