Question: #1250

CS 180 Programming Assignment 4 Complete Solution

Assignment #4 CS 180 Programming Fundamentals
Programming Assignment 4


Getting Started
This assignment emphasizes conditional statements, described in Chapter 3 of the textbook. Review in-class
examples and Handout 4.
Programming Project
HotelReservation: Calculate the cost of a hotel reservation. worth 10 points
An owner of a hotel chain has contracted you to write a program that will compute the amount due for
reserving a block of rooms in her hotels. The rules are as follows:
1. The regular rate per room is $250 per night.
2. Group rates apply to any reservation of 10 or more rooms and are as follows:
reservation of 10 - 25 rooms is billed by a standard group rate of $225 for reservations up to 2
nights long. Each additional night up to the 7th is billed $200 per room. Starting after the 7th
night, each room is billed $183.
if more than 25 rooms are reserved, the group rates are applied as described in the previous bullet,
plus the volume discount of 13% is applied to the total amount due.
3. Furthermore, hotels in Orlando and San Antonio are o ering a special promotion - 5% o of all non-
group reservations for 2 or more nights.
More speci cally, the program should ask the user to enter the following information
1. the number of rooms reserved,
2. the city of reservation,
3. the number of nights reserved.
and display the cost of the reservation.
The following sample interaction illustrates the execution of the program on a regular reservation without
the special promotion discount. User input is shown in boldface.
Starting a new reservation.
Please enter the number of rooms you wish to reserve: 2
The city where you'd like to make this reservation: New York
Now enter the number of nights: 3
The total cost of the reservation is $1,500.00 dollars.
In the above case, the charges include $250.00 for 2 rooms for 3 nights, i. e. 250 2 3 = 1; 500.
The next interaction shows a case in which the group rates were applicable.

Starting a new reservation
Please enter the number of rooms you wish to reserve: 50
The city where you'd like to make this reservation: Seattle
Now enter the number of nights: 3
Applying GROUP reservation rates.
The total cost of the reservation is $28,275.00 dollars.


In this interaction, the charges before the volume discount is applied include 50 225 2 = 22; 500 (the rst
two nights are charged $225 per night) plus 50 200 (3􀀀2) = 10; 000, since the one remaining night would be charged $200. The charge before the discount is therefore 22; 500 + 10; 000 = 32; 500. Since more than 25 rooms were reserved, the volume discount of 13% results in the nal price of $28,275.00 dollars.


Notes and Hints: Note that the above examples do not represent all possible scenarios of computing the
cost of a reservation. You should work out all of the possible scenarios and gradually develop a program
that handles all of them. Processing regular reservations is easier, so that's a good starting point.
In this program, there are a lot of data parameters, such as rates, discounts and cut-o numbers, which you should remember to represent using named constants. For example, to de ne the number of rooms required for the group rates to apply,
final int GROUP_MIN = 10; // minimum number of rooms required for a group reservation
Grading. Partial credit will be awarded, as always, but your program must compile without errors and
run. The grading schema is as follows:
2 points for correctly reading the input and displaying the amount in a formatted way as shown.
3 points for correctly processing the non-group reservations,
4 points for correctly processing the group reservations,
1 point for good programming style. The style requirements have been introduced in class and in
the earlier homework assignments.
Good luck and Happy Programming!
 

Solution: #1241

CS 180 Programming Assignment 4 Complete Solution

This Tutorial is rated A+ p...

Tutormaster
Rating: A+ Purchased: 11 x Posted By: Studyacer
Comments
Posted by: Studyacer

Online Users