Question: The application should handle the following conversions: From To Conversion Miles Kilometers 1 mile = 1.6093 kilometers Kilometers Miles 1 kilometer = 0.6214 miles Feet
The application should handle the following conversions:
From
To
Conversion
Miles
Kilometers
1 mile = 1.6093 kilometers
Kilometers
Miles
1 kilometer = 0.6214 miles
Feet
Meters
1 foot = 0.3048 meters
Meters
Feet
1 meter = 3.2808 feet
Inches
Centimeters
1 inch = 2.54 centimeters
Centimeters
Inches
1 centimeter = 0.3937 inches
Open the Chapter10-1LengthConversions project attached to this assignment. Display the code for the form, and notice the rectangular array whose rows contain the value to be displayed in the combo box, the text for the labels that identify the two text boxes, and the multiplier for the conversion as shown in the table above.
Set the DropDownStyle property of the combo box to DropDownList so the user must select an item from the list.
Add code to load the combo box with the first element in each row of the rectangular array when the form is loaded. Add code to display the first item in the combo box by setting the SeletedIndex property of the combo box when the form is loaded.
Add code to change the labels for the 2 text boxes, clear the calculated length, and move the focus to the entry text box when the user selects a different item from the combo box by using the SelectedIndexChanged event handler of the combo box.
Test the application to be sure the conversions are displayed in the combo box, the first conversion is selected by default, and the labels change appropriately when a different conversion is selected.
Add code to calculate and display the converted length when the user clicks the Calculate button. To calculate the length, you can get the index for the selected conversion and then use that index to get the multiplier from the array and convert it to decimal. Then multiply the lengh by the conversion multiplier to get the converted length. Test the application to be sure this works correctly.
Add validation code to check for valid data (IsValidData()) by seeing that that the user enters a value for the length using IsPresen() and that the value entered is a valid decimal value using IsDecimal().
Then, test the application one more time to be sure the validation works correctly.
When you?re done, press the Esc key to end the application.
This is the code:
Program.cs
using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms;
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 Conversions { ? ? public partial class Form1 : Form ? ? { ? ? ? ? public Form1() ? ? ? ? { ? ? ? ? ? ? InitializeComponent(); ? ? ? ? }
Conversions Conversion: Meters to feet Meters 500 Feet 1.640.40 Calculate 0 Exit x
Step by Step Solution
★★★★★
3.51 Rating (151 Votes )
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
To complete this application you need to add functionality for loading combo box items changing labels based on selection performing conversions and v... View full answer
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
Students Have Also Explored These Related Programming Questions!