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

A market sells eggs at $1.90 per dozen, milk at $1.47 per quart, and bread at $2

ID: 3539785 • Letter: A

Question

A market sells eggs at $1.90 per dozen, milk at $1.47 per quart, and bread at $2.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

Hi ,

I developed the code. The site was down for maintenance so i couldn't paste it earier

The entire project is at http://ge.tt/54VMHam/v/0?c


If you want only the code, then use this... Hope it helps :)


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;


namespace OrderApp

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}



int breadcount = 0;

int eggcount = 0;

int milkcount = 0;

private void btnOrder_Click(object sender, EventArgs e)

{

if (comboItemsList.SelectedIndex == -1)

{

MessageBox.Show("Please select an item to purchase");

return;

}

else if (txtItemCount.Text == "")

{

MessageBox.Show("Please Enter Quantity ");

return;

}

try

{

int i = Convert.ToInt32(txtItemCount.Text);

}

catch (Exception exc)

{

MessageBox.Show("Quantity must be numeric");

return;

}


if (comboItemsList.SelectedIndex == 0)

{

eggcount = Convert.ToInt32(txtItemCount.Text);

}

else if (comboItemsList.SelectedIndex == 1)

{

milkcount= Convert.ToInt32(txtItemCount.Text);

}

else if (comboItemsList.SelectedIndex == 2)

{

breadcount = Convert.ToInt32(txtItemCount.Text);

}



txtOutput.Text = "You have ordered: " + Environment.NewLine +" "+ eggcount + " dozen eggs = $" + (eggcount * 1.90) + Environment.NewLine

+ " " + milkcount + " quart(s) of milk = $" + (milkcount * 1.47) + Environment.NewLine

+ " " + breadcount + " loaf(s) of bread = $" + (breadcount * 2.12) + Environment.NewLine + Environment.NewLine;




}


private void btnTotal_Click(object sender, EventArgs e)

{

txtOutput.Text = "You have ordered:" + " "+ Environment.NewLine + eggcount + " dozen eggs = $" + (eggcount * 1.90) + Environment.NewLine

+ " " + milkcount + " quart(s) of milk = $" + (milkcount * 1.47) + Environment.NewLine

+ " " + breadcount + " loaf(s) of bread = $" + (breadcount * 2.12) + Environment.NewLine + Environment.NewLine

+ " Your Final Total is = $" + ((eggcount * 1.90) + (milkcount * 1.47) + (breadcount * 2.12)) + Environment.NewLine + Environment.NewLine

+ " Please Click X on the right upper corner of the screen when you are ready to exit";

}

}

}






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