Question
Operation This application calculates the charges for a stay at a hotel based on the arrival and departure dates. The application begins by prompting the
Operation This application calculates the charges for a stay at a hotel based on the arrival and departure dates. The application begins by prompting the user for the month, day, and year of the arrival and the departure. Next, the application displays the arrival date, the departure date, the room rate, the total price, and the number of nights.
Specifications Create a class named Reservation that defines a reservation. This class should contain instancevariables for the arrival date and departure date. It should also contain a constant initialized to thenightly rate of $115.00. The Reservation class should contain a constructor that accepts the arrival and departure dates asparameters of type Date, as well as methods that return the number of nights for the stay (calculatedby subtracting the arrival date from the departure date) and the total price (calculated by multiplyingthe number of nights for the stay by the nightly room rate). This class should also override thetoString method to return a string like this:
Arrival Date: Monday, May 16, 2005Departure Date: Wednesday, May 18, 2005Price: $115.00 per nightTotal price: $230.00 for 2 nights The main method for the application class should contain a loop that asks the user for the arrival anddeparture date information, creates a Reservation object, and displays the string returned by thetoString method. Assume valid data is entered.
Enhancements Add validation so the user must enter values that will result in a correct date. Allow the user to enter the date in the form mm/dd/yyyy. Allow the user to enter the room rate or select the rate from one of several available rates. Use the BigDecimal class rather than the double type for the price calculation.
Note This application requires the use of the GregorianCalendar class to create dates from the int valuesentered by the user. Then, it requires the use of the getTime method to convert the GregorianCalendarobject to a Date object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started