Assessment item 1—Java Console Program

The Rocky Budget Hotel management has asked you to write a program to help employees determine the charges for customers staying at their hotel and to also produce some statistics.

You are to write a Java Console Application (Hotel.java) which will allow employees to enter the details of N customers’ names and the number of days to stay at the Rocky Budget Hotel. N should be equal to the highest digit in your student ID, use N=3 if your highest digit is less than three. For each customer the program will prompt for and accept the name of the customer and the length of stay at the hotel (in whole days), it will then display the total cost of the stay (see sample output below for formatting details).

The pricing structure for staying at the hotel is (maximum fourteen days):

The first day will cost \$110.

The next two days will cost \$100 per day.

The next four days will cost \$90 per day.

The next week will cost \$70 per day.

The sliding price scale is to encourage customers to stay longer at the Rocky Budget Hotel, the management has imposed a maximum of fourteen days stay, after that the pricing structure will repeat with another booking needed to be made.

When all customer’ names and days to stay have been entered you need to report the maximum and minimum stay (in days) and the relevant customer’s name, the average stay and the total charges which have been collected.

The required Java Console Application should allow the user to:

1) For each of the N customers: enter the Name, and then enter the Length of stay in whole days. The program will output the charge for the customer’s stay. All dollar values will be formatted to two decimal places (see implementation below with help for doing this).

2) You must ensure the name is not blank so you must implement a validation loop so a valid name is entered. The number of days must be between 1 and 14 inclusive and you will also need to implement a validation loop so valid days are entered.

The program will number each customer in the input prompt.

3) When N customers have been entered, you will output a heading for the statistics “Statistical information for the Rocky Budget Hotel”, the minimum and maximum stays (in days) and the name of the customers with these minimums and maximums, and then what the average stay is in days (formatted to two decimal places) (see sample output below). Note: if more than one customer has an equal maximum or minimum stay you just need to only output one of the customer’s name.

4) Display a welcome message at the beginning “Welcome to the Rocky Budget Hotel system” and an end message “Thank you for using the Rocky Budget Hotel system” and the final line “Program written by <your student ID>” (see sample output below).

The numeric literal values N and daily rates must be represented as constants.

Implementation

A large number of students have never written a program before so this is a fairly simple assignment which can be written in the main method of your class. Follow the steps outlined here and build your program up in a step by step fashion and always compile your program at each stage so you are always working on error free code.

Start by creating your Hotel class which will contain just the main method, COMPILE! (Fix any errors and repeat).

Implement the welcome message, COMPILE and RUN!

Create a loop to loop N Times, COMPILE! (use N = 3 for development).

Declare variables to hold the customer’s name and their length of stay (String and int), COMPILE!

Within the loop: prompt and read the customer’s name, COMPILE and RUN!

Add the prompt and read for the length of stay, COMPILE and RUN!

Calculate the charges using the pricing structure above, COMPILE, RUN and TEST until this is correct.

Output the description of the transaction (see sample output below)

Output all dollar values and average to two decimal places:

USE: System.out.printf(“%.2f “, charges);

Add the validation loops for reading the data (you can do this last if you like).

Use if statements to determine if the stay is maximum or minimum, (you will have to think about this). Output the minimum and maximums after the loop for testing, COMPILE and RUN until you have this correct. You may want to set your original max and min variables to very small and very

large numbers using Integer.MIN_VALUE and Integer.MAX_VALUE.

You will need to add up the days as you go so you can calculate the average.

After the loop, you will output the statistics which you have gathered in the loop. You should have the maximum and minimum stays and the corresponding customer names and the total amount of charges collected.

Calculate the average stay and output this to two decimal places.

Output the statistics as indicated in the screen shot below.

Finally print the end message.

Your program should be well laid out, commented and uses appropriate and consistent names (camel notation) for all variables and objects.

For this assignment you will not worry about checking data types.

Refer to a Java reference textbook and the unit and lecture material (available on the unit WEB site) for further information about the Java programming topics required to complete this assignment. Check the marking guide (last page) to ensure you have completed every task. You need to match the