Question
C# Code File: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Reservations { public
C#
Code File:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Reservations { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //public bool IsValidData() //{ //} public bool IsPresent(TextBox textBox, string name) { if (textBox.Text == "") { MessageBox.Show(name + " is a required field.", "Entry Error"); textBox.Focus(); return false; } return true; } //public bool IsDateTime(TextBox textBox, string name) //{ //} //public bool IsWithinRange(TextBox textBox, string name, // DateTime min, DateTime max) //{ //} private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }
Extra 9-1 Calculate reservation totals In this exercise, 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. Reservations Arrival date: 1/29/2016 Departure date: 2/1/2016 Number of nights: 3 Total price $420.00 Avg. price per night: $140.00 Calculate Ext Open the project and implement the calculations 1. Open the Reservations project in the Extra Exercises Chapter 09 Reservations directory. Then, display the code for the form and notice that some of the methods are commented out so they don't return errors. 2. Add code to get the arrival and departure dates the user enters when the user clicks the Calculate button. Then, calculate the number of days between those dates, calculate the total price based on a price per night of $120, calculate the average price per night, and display the results. 3. Test the application 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 4. 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. 5. Modify the code so Friday and Saturday nights are charged at $150 and other nights are charged at $120. One way to do this is to use a while loop that checks the day for each date of the reservation. 6. Test the application to be sure that the default dates are displayed correctly and that the totals are calculated correctly. Add code to validate the dates 7. Uncomment the IsDate Time method and then add code to check that the arrival and departure dates are valid dates. 8. Uncomment the Is WithinRange method and then add code to check that the arrival and departure dates are within a range that includes the minimum and maximum dates that are passed to it. 9. Uncomment the Is ValidData method and then add code that uses the IsPresent, IsDateTime, and IsWithinRange 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. 10. Add code that uses the Is ValidData method to validate the arrival and departure dates. In addition, add code to check that the departure date is after the arrival date. 11. Test the application to be sure the dates are validated properlyStep 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