Calculate the average number of nights per booking

Assignment Help JAVA Programming
Reference no: EM133338550

Yeppoon Cabins program

Yeppoon Budget Cabins are offering cabins at $89.95 per night. For each booking irrespective of the number of days there is a one-off cleaning fee of $20.00. If the customer books one night, the total charge will be $109.95, two nights will be $199.90 etc. To encourage customers to book more nights, the management has decided to give a ten percent discount for a booking with more than seven nights and a fifteen percent discount with a booking of more than fourteen nights on the total nights of stay charge. This will not apply to the one-off cleaning fee, do a Java Console Application (YeppoonCabins.java) which will allow staff to enter the details of N booking names and the number of nights. 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 booking the program will prompt for and accept the booking name and the number of nights, it will then display the charge (see sample output below for formatting details). When all the bookings have been entered you need to report the maximum and minimum number of nights per booking and the relevant booking name, the average number of nights per booking and the total charges which have been collected.

The required Java Console Application should allow the user to:

 1. For each of the N bookings: enter the booking name, and then enter the number of nights. The program will output the charge for the booking. All dollar values will be formatted to two decimal places (see implementation below with help for doing this). 

2. You must ensure the booking name is not blank so you must implement a validation loop to ensure that a booking name is entered. For this assignment, there is no need to ensure the name is a valid name (e.g. entering 1 for the name would be allowed). The number of nights must be greater than or equal to one and you will also need to implement validation loop to ensure that a valid number of nights is entered. 

Sample pseudocode for a validation loop:

 Prompt and read a value WHILE the value is incorrect PRINT error Prompt and read a value

 (again) END WHILE

 The program will number each booking in the input prompt. 

3. When N bookings have been entered, you will output a heading for the statistics "Statistical information for Yeppoon Cabins", the minimum and maximum number of nights booked and the booking names with these minimums and maximums, and then what the average number of nights per booking is (formatted to two decimal places) (see sample output below). Note: If more than one booking has an equal maximum or minimum nights you just need to only output one of these cases. 

4. Display a welcome message at the beginning "Welcome to the Yeppoon Cabins Management System" and an end message e.g. "Thank you for using the Yeppoon Cabins Management System" and the final line "Program written by " (see sample output below). The numeric literal values N, number of nights for the different discount levels, discounts and nightly cost must be represented as constants.

Implementation

Many 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 Yeppoon Cabins class which will contain just the main method, COMPILE! (Fix any errors and repeat). 

Please include a header comment which includes your name, student ID, date, filename and a brief description of the program.

Implement the welcome message, COMPILE, RUN and TEST! Declare your Scanner object(s), COMPILE! Note: In order to combat the problem of the Scanner objects reading both textual and numeric data a good way to counter this is to declare two Scanner objects, one for reading text and another for reading numbers, or you can clear the buffer after the int read using nextLine(). 

This might not be considered "best practise" but will be sufficient for this unit. 

make a loop to iterate N Times, COMPILE, RUN and TEST! (use N = 3 for development

Declare variables to hold the booking name and the number of nights (String and int), COMPILE, RUN and TEST!

 Within the loop: prompt and read the booking name, COMPILE, RUN and TEST!

 Add the prompt and read for the number of nights, COMPILE, RUN and TEST!

 Calculate the booking charges using the discount structure above, COMPILE, RUN and TEST until this is correct

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

 Output all dollar values and average to two decimal places: 

USE: System.out.printf("%.2f", charge);

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

Use if statements to determine if the number of nights is a maximum or minimum, (you will have to think about this). Output the minimum and maximums after the loop, COMPILE and RUN until you have this correct. You may want to set your original max and min variables to the minimum and maximum integers values using Integer.MIN_VALUE and Integer.MAX_VALUE.

 You will need to add up the number of nights booked 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 number of nights and the corresponding booking names and the total amount of charges collected.

Calculate the average number of nights per booking (ensure you are performing a floating-point calculation). Output the statistics as indicated in the screen shot below. 

Finally, print the end message. Your program should be well laid out, commented, and use appropriate and consistent names (camel notation) for all variables and objects.

Reference no: EM133338550

Questions Cloud

What are leading causes of death for young people : Medical care spending has increase significantly in the last 60 years. What are the leading causes of death for young people?
Demonstrates that the attorney shall disclose : GOVT 325 Liberty University demonstrates that the attorney shall disclose the discrepancy within the matter but is not obligated to disclose the name
Types of conflicts that exist in the short story : Mention at least two types of conflicts that exist in the short story, Touching Bottom? Give examples from the story for each one.
Explain the main principle of maternity : Explain the main principle of maternity, paternity, and adoption rights in the context of employment rights.
Calculate the average number of nights per booking : Calculate the average number of nights per booking (ensure you are performing a floating-point calculation). Output the statistics as indicated in the screen
Define comparative advantage : Define comparative advantage. what is for sale in the factor markets? Give an example from your household.
What is the corresponding total annual cost : What is the optimal order size for this item, and what is the corresponding total annual cost?
How would you search to find the best candidates : How would you search to find the "best" candidates to interview for the Medical Coding Supervisor position? What sources would you use and what qualities are
Identify any potential risks in taking the accounts : Identify any potential risks in taking the accounts receivable owed by these Mexican retail stores as collateral for a loan. What do you advise them and why

Reviews

Write a Review

JAVA Programming Questions & Answers

  Display the list of integers and their sum

Prompt a user to enter a series of integers separated by spaces and accept the input as a String. Display the list of integers and their sum.

  Technical community blog

Write a blog article for a coding and technical community blog.

  Write a java program that can serve as a simple calculator.

Write a Java program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0.

  Creating java applications using java se and an ide

Discussion Question: How does Java provide platform portability for developing applications? Describe the process to creating Java applications using Java SE and an IDE

  Consider the following conditions

Consider the following conditions: An enqueuer waiting on a full-queue or a dequeuer waiting on an empty queue sleep indefinitely, unless woken up by another thread. A thread must send a signal ONLY when it adds an element to an empty queue or remove..

  Write a java application titled mystringtest

Write a Java application titled MyStringTest that creates an instance of the String class and initializes this instance with a String literal.

  What is the output of the following program

How can you tell whether an exception is checked or unchecked? What is required of checked exceptions that is not required of those that are unchecked? What is the output of the following program

  Design a class named large integers

Design a class named largeIntegers such that an object of this class can store an integer of any number of digits.

  Implement the methods in the myhashtable

Implement the methods in the MyHashTable - All methods of the Graph class are implemented for you - Implement the traverseFrom

  Illustrate how to create a bufferedinputstream

What are Buffered Input / Output Streams and why are they used - write some Java code to illustrate how to create a BufferedInputStream.

  Write a java program to compute salary

Write a Java program which computes the Salary for a given number of employees. The program prompts user to enter n the number of employees.

  Create seats for a flight

Create an airport: An airport must have a name consisting of exactly three alphabetic characters. No two airports can have the same name

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd