Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Upload the code In this assignment, you'll add code that calculates the number of nights, total price, and average price for a reservation based on
Upload the code
In this assignment, you'll add code that calculates the number of nights, total price, and average price for
a reservation based on the arrival and departure dates the user enters.
Open the project and implement the calculations
Open the Reservations project attached here with this assignment and review the code for
the form. Notice that it contains event handlers for the click events of the Calculate and
Exit buttons, plus several data validation methods.
Modify the Click event handler for the Calculate button so it gets the arrival and
departure dates the user enters. Then, calculate the number of days between those dates,
calculate the total price based on a price per night of $ calculate the average price per
night, and display the results.
Test the app to be sure it works correctly. At this point, the average price will be the same
as the nightly price.
Enhance the way the form works
Add an event handler for the Load event of the form. This event handler should get the
current date and three days after the current date and assign these dates to the Arrival
Date and Departure Date text boxes as default values. Be sure to format the dates as
shown above. Modify the Click event handler for the Calculate button so Friday and Saturday nights are
charged at $ and other nights are charged at $ One way to do this is to use a while
loop that checks the day for each date of the reservation.
Test the app to be sure that the default dates are displayed correctly and that the totals are
calculated correctly.
Add code to validate the dates
Add code to the IsDateTime method that checks that a value is a valid date.
Add code to the IsWithinDateRange method that checks that a value is within a date
range that includes the minimum and maximum dates that are passed to it
Add code to the IsLaterDate method that compares the two values passed to it and
makes sure the second value is later than the first value.
Add code to the IsValidData method that uses the IsDateTime IsWithinDateRange
and IsLaterDate methods to validate the arrival and departure dates. These dates should
be in a range from the current date to five years after the current date, and the departure
date should be later than the arrival date.
Modify the Click event handler for the Calculate button so it uses the IsValidData
method to validate the arrival and departure dates.
Test the app to be sure the dates are validated properly.
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