Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make this program check for multiple things one-at-a-time?
    text
    copied!<p>/<em>At the bottom of this code there are two if statements. I want to be able to check FIRST whether the user has selected a flavor(the text for the flavor textbox is "Select a flavor" by default). If they click the AddDrink button without selecting a flavor, the message box needs to show that they haven't selected a flavor, instead of haven't entered a quantity, and then proceed with the program. However, if they have chosen a flavor but haven't entered a quantity then it should show the message box about entering a quantity. If anymore info is needed please let me know. THANKS FOR YOUR HELP!!!</em>/</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Chap9DrinkApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void ComputeCost_CheckedChanged(object sender, EventArgs e) { } private void btnCompleteOrder_Click(object sender, EventArgs e) { MessageBox.Show(lblFinalFlavor.Text + "\n" + lblFinalTopping.Text + "\n" + lblFinalCost.Text); } private void btnAddDrink_Click(object sender, EventArgs e) { double cost = 0; double quantityPrice; double quantityNum; this.lblFinalTopping.Text = "Extras: "; if (this.radSmall.Checked) { cost += 3.00; } else if (this.radMedium.Checked) { cost += 3.50; } else if (this.radLarge.Checked) { cost += 4.00; } if (this.ckBoxCherries.Checked) { cost += .50; this.lblFinalTopping.Text += "Cherries "; } if (this.ckBoxGrape.Checked) { cost += .50; this.lblFinalTopping.Text += "Grapes "; } if (this.ckBoxLemon.Checked) { cost += .50; this.lblFinalTopping.Text += "Lemon "; } if (this.ckBoxPineapple.Checked) { cost += .50; this.lblFinalTopping.Text += "Pineapple "; } if (this.ckBoxStrawberry.Checked) { cost += .50; this.lblFinalTopping.Text += "Strawberry "; } if (this.ckBoxVitamin.Checked) { cost += .50; this.lblFinalTopping.Text += "Vitamin Pack "; } if (this.ckBoxWhipped.Checked) { cost += .50; this.lblFinalTopping.Text += "Whipped cream "; } this.lblFinalCost.Visible = true; if (this.txtQuantity.Text != "0") { quantityNum = double.Parse(this.txtQuantity.Text); quantityPrice = cost * quantityNum; this.lblFinalCost.Text = "Cost: " + quantityPrice.ToString("c"); } else MessageBox.Show("Please enter a quantity!"); if (this.cmboBoxJuiceFlav.Text != "Select a flavor") this.lblFinalFlavor.Text = "Flavor: " + this.cmboBoxJuiceFlav.Text; else MessageBox.Show("Please select a flavor!"); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload