Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm stuck on this, thank you for any help you guys can provide. In this exercise, youll add code that calculates 1. the number of

I'm stuck on this, thank you for any help you guys can provide.

In this exercise, youll add code that calculates

1. the number of nights,

2. total price,

3. and average price

for a reservation based on the arrival and departure dates the user enters.

image text in transcribed

Open the project and implement the calculations

display the code for the form and notice that some of the methods are commented out so they dont return errors.

2. Add code to get the arrival and departure dates the user enters when the user clicks the Calculate button.

1. Then, calculate the number of days between those dates,

2. calculate the total price based on a price per night of $120,

3. calculate the average price per night,

4. 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 IsDateTime method and then add code to check that the arrival and departure dates are valid dates.

8. Uncomment the IsWithinRange 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 IsValidData 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 IsValidData 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 properly.

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(); }

Reservations Anrival date 1/29/2016 Departure date: 2/1/2016 Number of nights: 3 Total price: $420.00 Avg. price per night: $140.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

Be familiar with the five basic ways to manage demand.

Answered: 1 week ago