Question: Write a Windows Forms application for converting between miles and kilometres using c#(note if possible pls show the output ) For this exercise you are
Write a Windows Forms application for converting between miles and kilometres using c#(note if possible pls show the output )
For this exercise you are asked to write a Windows Forms application to allow users to convert between miles and kilometres. Note that, as per the Wikipedia page for 'Mile', one mile is exactly 1609.344 metres.
Create a GUI with the following elements:
A Form with the caption 'Miles and Kilometres Converter'. This form must be named Form1
A RadioButton with the text 'Miles to Kilometres'
A RadioButton with the text 'Kilometres to Miles'
A TextBox where the user can enter in a number.
A Label with the text 'Enter distance:' telling the user to enter a distance into the text box.
A Button with the text 'Convert', which causes the distance entered to be converted.
A Label with the text 'Distance in kilometres is ___' or 'Distance in miles is ___', depending on the conversion being done, and with ___ replaced with the converted distance.
You can arrange the form however you choose; here is an example of how it could potentially be laid out:
The only formatting requirement for this task is that we require you to use the following fonts for the form elements:
Miles to kilometres radio button: 12pt Tahoma (italic)
Kilometres to miles radio button: 20pt Times New Roman (bold and italic)
Convert button: 16pt Verdana (italic)
Distance text box: 20pt Courier New (bold)
"Enter distance:" label: 14pt Trebuchet MS
Output label: 20pt Tahoma (italic)
Here's some implementation details for this exercise:
The form must be named Form1. This is the Visual Studio default and is necessary for the tester to find your form.
The namespace that Form1 appears in must be named MilesToKm.
The 'Miles to Kilometres' and 'Kilometres to Miles' radio buttons control the type of conversion to perform when 'Convert' is clicked. So if 'Miles to Kilometres' is checked, "80" is entered into the text box and the 'Convert' button is clicked, a label with 'Distance in kilometres is 128.75' should appear.
Likewise, if 'Kilometres to Miles' is selected, entering "80" and clicking the button should display 'Distance in miles is 49.71' should be displayed.
The output label (the label where the distance in miles/kilometres is displayed) should be hidden until 'Convert' is first clicked.
If 'Convert' is clicked and there isn't a number in the text box the output label must say 'Invalid input' instead of 'Distance in kilometres is ___' or 'Distance in miles is ___'
The 'Miles to Kilometres' checkbox should be checked when the form is first run.
Do not hide or disable any form controls unless you are explicitly told to do so in the instructions.
General tips for writing GUI programs
See Activity 1: Simple GUI Development in the Week 8 Practical Worksheet for a guide to creating a simple GUI program.
For this activity you are not given sample code because Visual Studio creates a substantial framework for you already.
Here are some specific points to ensure when you are working on your program to ensure that AMS can work with it:
Make sure you create a Visual C# Windows Forms App (.NET Framework) when creating the project in Visual Studio.
The solution should be named MilesToKm. This is not necessary; however the namespace must be named MilesToKm and naming the solution MilesToKm is a good way to ensure that it is correct by default.
The form must be named Form1. This is the default form name when creating a Windows Forms App.
Ensure that your buttons, captions etc. contain the text they are required to. The names of the buttons in the source code is irrelevant; however, the text on the buttons is used to find them within the form. The same is true for labels, checkboxes and any other form elements.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
