Question
This lab covers material from Chapter 5 as well as concepts from previous chapters. The purpose of this lab is to demonstrate the use of
This lab covers material from Chapter 5 as well as concepts from previous chapters. The purpose of this lab is to demonstrate the use of the appropriate repetition structure as well as to prevent data conversion exceptions using the TryParse method and implement appropriate accuracy validation. Accumulators, counters, and averages are also implemented. This is done using C# language in Visual Studio. 1. Complete Programming Problem #1, Distance Calculator, on page 339 of the textbook.
The ADDITIONAL REQUIREMENTS described below MUST also be implemented:
- Assume the value of Vehicle Speed in MPH may store whole or floating-point numbers (non-monetary).
- Assume the value of Hours Traveled can only store whole numbers.
- Prevent data conversion exception for the Vehicle Speed in MPH text box by using the appropriate TryParse method. If the data entered is invalid display an appropriate error message to the user, set the focus back to the text box causing the error, and either clear the text box or select all the data entered into it so that it can be replaced.
- Validate the input for the Vehicle Speed in MPH to make sure the data entered is greater than zero and does not exceed 180. If not, display an appropriate error message to the user, set the focus back to the text box causing the error, and either clear the text box or select all the data entered into it so that it can be replaced.
- Prevent data conversion exception for the Hours Traveled text box by using the appropriate TryParse method. If the data entered is invalid display an appropriate error message to the user, set the focus back to the text box causing the error, and either clear the text box or select all the data entered into it so that it can be replaced.
- Validate the input for Hours Traveled to make sure the data entered is greater than zero and not more than 50. If not, display an appropriate error message to the user, set the focus back to the text box causing the error, and either clear the text box or select all the data entered into it so that it can be replaced.
- Implement the following fields:
- Total Distance which accumulates the distance for each entry (i.e., as shown in the ListBox control)
- Total Hours Traveled which accumulates the hours traveled for each entry (i.e., as entered in the Hours Traveled TextBox control)
- Total Trips which counts each entry (i.e., incremented each time the user clicks the Calculate Button control)
- Display appropriate output to the ListBox control as shown in the sample input-output document attached.
- Display Total Distance as a number with two-decimal places.
- Display Total Hours Traveled and Total Trips as a number with no decimal places.
- Calculate and display the Average Distance which is the Total Distance divided by the Total Trips (recall, average distance is not an accumulator or counter) formatted as a number with two-decimal places.
The program MUST include standard features of a Windows application including:
- Change the default Text property of the form to something descriptive
- Appropriate naming conventions for all controls (i.e., buttons, labels, text boxes, list). The standard naming convention is descriptive name including control type using camelCase notation. For example: hoursTraveledTextBox, distanceListBox, totalHoursTraveledLabel, exitButton. The exception is controls not referenced in the code-behind of Form1. For example, Label controls used for descriptive purposes only or PictureBox controls used for aesthetic purposes only.
- Calculate, Clear, and Exit buttons with appropriate name and keyboard access key
- AcceptButton and CancelButton properties should be appropriately assigned to the Calculate button and Clear button, respectively
- Ensure tab order for form is logical
- When Clear button is clicked the controls outside of the Summary GroupBox control should be cleared (i.e. using the Clear method or assigning an empty string) and the focus set back to the first TextBox control for entering data. The controls inside the Summary GroupBox control should NOT be cleared (i.e., using the Clear method or assigning an empty string). Do NOT reset the values of the fields to zero.
- Appropriate naming conventions and data type declarations for variables and fields.
- Remove all unused event handlers from the program code.
2. Name your project using the naming convention provided in the syllabus: CourseNumber_LastNameFirstInitial_LabXX (e.g., 3333_SharpJ_Lab04)
3. Include the appropriate identification information per the course syllabus using comment statements at the top of your project code (see p. 102, 2.8 Comments, Blank Lines, and Indentation): Name, 9-Digit ID, Due Date, Date Submitted, and Brief Description of Program.
4. You will need to zip/compress the project folder using an appropriate zip/compression utility such as the one found in the Windows or WinZip, etc. Please DO NOT submit .rar (archive) files.
5. Attach and submit the zipped/compressed project folder file under the Lab 04 link under Assessments in the Chapter 5 Module.
6. See Revised Form based on Additional Requirements below. A PDF document with sample input-output is attached:
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