I am writing a program that calculates total cost for shipping bees here is the code so far:
if (this.comboBox1.SelectedIndex == 0)
{
int VIC = 12;
if (this.comboBox1.SelectedIndex == 1) ;
int NT = 15;
if (this.comboBox1.SelectedIndex == 2) ;
int ACT = 15;
if (this.comboBox1.SelectedIndex == 3) ;
int QLD = 20;
if (this.comboBox1.SelectedIndex == 4) ;
int SA = 15;
if (this.comboBox1.SelectedIndex == 5)
{
int WA = 25;
float queen = Convert.ToInt32(textBox1.Text);
float worker = Convert.ToInt32(textBox2.Text);
float calc1 = queen * 15;
double calc2 = worker * 0.05;
double calc3 = calc1 + calc2 + WA;
label2.Text = "Total cost: $" + calc3;
}
else if (this.comboBox1.SelectedIndex == 6)
{
int TAS = 15;
float worker = Convert.ToInt32(textBox2.Text);
float queen = Convert.ToInt32(textBox2.Text);
float calc1 = queen * 15;
double calc2 = worker * 0.05;
double calc3 = calc1 + calc2 + TAS;
label2.Text = "Total cost: $" + calc3;
But when I run the program, use all the text box spaces as intended and select a shipping option from the combo box (one of the two that I have so far written it for) and submit the inputs nothing shows up in label. It stays blank as "Total cost: "(Which it is set as by default in the properties).
I have tried tweaking with the braces and if else statements, that either yields no results (same problem as just described) or the program runs through and executes the code until the last time it sees "label2.Text = "Total cost: $" + calc3;". Which will then display on label2. Which also isn't helpful because if I choose WA which has $25 shipping it will instead display the TAS shipping which is $15.
Aucun commentaire:
Enregistrer un commentaire