C# Beginner - Online Student Project
-
I am a 100% online student trying to learn C#. My instructor has not been of help, so I am looking for help elsewhere. My homework is to create a program that will convert measurements: "
In the English measurement system, 1 yard equals 3 feet and 1 foot equals 12 inches. Use this information to create an application that lets the user convert distances to and from inches, feet, and yards. Use list boxes for the user to select units being converted from and another list box for the user to select units being converted from.
Write your code in the following order
Program must check for correct input into the textbox. Hint: use TryParse.
Check that user has selected a from unit. If not, let user know no unit has been selected.
Check that user has selected a to unit. If user selects the same unit for both from and to, let them know that they need to select a different unit." I believe I have my TryParse correct. It will make sure a measurement has been entered, a from distance has been selected and a to distance has been selected. After that, I am not sure where to proceed. I don't know how to grab what is selected in the from groupbox to the to groupbox and then convert. Any help would be appreciated. Thanks!
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 Distance_Converter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void convertButton\_Click(object sender, EventArgs e) { double distanceInput; double inches; double feet; double yards; string measurementFrom; if (double.TryParse(distanceTextBox.Text, out distanceInput)); { if (fromListBox.SelectedIndex != -1) { if (toListBox.SelectedItem = != -1) { } } } } }
}
Image of UI: Capture — imgbb.com[^]
-
I am a 100% online student trying to learn C#. My instructor has not been of help, so I am looking for help elsewhere. My homework is to create a program that will convert measurements: "
In the English measurement system, 1 yard equals 3 feet and 1 foot equals 12 inches. Use this information to create an application that lets the user convert distances to and from inches, feet, and yards. Use list boxes for the user to select units being converted from and another list box for the user to select units being converted from.
Write your code in the following order
Program must check for correct input into the textbox. Hint: use TryParse.
Check that user has selected a from unit. If not, let user know no unit has been selected.
Check that user has selected a to unit. If user selects the same unit for both from and to, let them know that they need to select a different unit." I believe I have my TryParse correct. It will make sure a measurement has been entered, a from distance has been selected and a to distance has been selected. After that, I am not sure where to proceed. I don't know how to grab what is selected in the from groupbox to the to groupbox and then convert. Any help would be appreciated. Thanks!
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 Distance_Converter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void convertButton\_Click(object sender, EventArgs e) { double distanceInput; double inches; double feet; double yards; string measurementFrom; if (double.TryParse(distanceTextBox.Text, out distanceInput)); { if (fromListBox.SelectedIndex != -1) { if (toListBox.SelectedItem = != -1) { } } } } }
}
Image of UI: Capture — imgbb.com[^]
Silly person - only post in one forum as duplicating the question will irritate the responders and duplicate the work!
Never underestimate the power of human stupidity RAH
-
Silly person - only post in one forum as duplicating the question will irritate the responders and duplicate the work!
Never underestimate the power of human stupidity RAH
Figured out this would probably be the better place. Delete was disabled on other post.