Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a. A market sells eggs at $4.9 per dozen, milk at $3.25 per quart, and bread at

ID: 3630269 • Letter: A

Question

a. A market sells eggs at $4.9 per dozen, milk at $3.25 per quart, and bread at $5.12 per loaf. Use a combo box to allow the user to select an item, and a text box for the user to input the quantity desired. Include an Order button to allow the user to order the specified quantity of the selected item. When the user presses the Order button, a description and the total cost of the order should appear in the form.
b. Allow the user to order more than one type of food. Each time the user presses the order button, describe the purchase. Add a Total button, and when the user presses this button, display the total prices of all items ordered.

Explanation / Answer

{

InitializeComponent();

this.label1.Text = "";

this.button1.Text = "Order";

this.comboBox1.Items.Add("Eggs by dozen");

this.comboBox1.Items.Add("Milk by quart");

this.comboBox1.Items.Add("Bread by loaf");

this.comboBox1.SelectedIndex = 0;

void button1_Click(object sender, EventArgs e)

{

int choice = this.comboBox1.SelectedIndex;

int quantity = Int32.Parse(this.textBox1.Text);

double price = 0;

switch (choice)

{

case 0:

// the user ordered eggs

price = 4.9 * quantity;

this.label1.Text = "You ordered Eggs for a total of $" + price;

break;

case 1:

// the user ordered milk

price = 3.25 * quantity;

this.label1.Text = "You ordered Milk for a total of $" + price;

break;

case 2:

// the user ordered bread

price = 5.12 * quantity;

this.label1.Text = "You ordered Bread for a total of $" + price;

break;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote