This Needs To Be Done In Visual C Drink Vending Machine Simu

This Needs To Be Done In Visual C#

Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let the user select one of the following soft drinks: • Cola ($1.00 each) • Root Beer ($1.00 each) • Lemon Lime Soda ($1.00 each) • Grape Soda ($1.50 each) • Cream Soda ($1.50 each)

Figure 8-22shows an example of the application’s form. (The images that are displayed in the PictureBox controls are in the Images\\ Drink Machine folder of the

Figure 8-22 Drink vending machine simulator Student Sample Programs.)

When the application starts, the vending machine will have 20 of each type of soft drink. Each time the user selects a drink, the application should subtract 1 from the quantity of the selected drink. It should also update and display the total amount of sales. If the user selects a drink that is sold out, a message should be displayed indicating so. In the application’s code, create a structure that has fields for the following data: Drink name Drink cost Number of drinks in machine The program should create an array of five structure objects. Each element of the array should keep data for a specific type of soft drink.

I need the form to be clickable pictures and auto updating drinks left labels and total label.

I have currently made the form, for the drinks remaining and totalsales i have used labels they are named as follows

coladrinksleft

creamsodadrinksleft

grapesodadrinksleft

lemonlimesodadrinksleft

rootbeerdrinksleft

totalsalesoutput

the code i have needs to basically be completely done, all that i have is the picture clicks and an exit button but here is the code that needs to be completed.

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 drinkvendingmachine
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void exitbtn_Click(object sender, EventArgs e)
{
this.Close();
}

private void colapic_Click(object sender, EventArgs e)
{

}

private void creamsodapic_Click(object sender, EventArgs e)
{

}

private void grapesodapic_Click(object sender, EventArgs e)
{

}

private void lemonlimesodapic_Click(object sender, EventArgs e)
{

}

private void rootbeersodapic_Click(object sender, EventArgs e)
{

}
}
}

Solution

Create an application that simulates a soft-drink vending machine.The application should let the user select one of the drinks:

using System;

using System.Collections.Gneric;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.text;

using System.Windows.Forms;

namespace Windows.FormsApplication1

{

struct Drinks

{

public string drinkname;

public string drinkcost;

public string inventory;

}

public partial class VendingMachine:Form

{

public VendingMachine()

{

InitializeComponent();

}

int grapeTotal = 0;

int lemonTotal = 0;

int rootTotal = 0;

int colaTotal = 0;

int creamTotal = 0;

int cokeTotal;

int rootbeartotal;

int lemonlimeTotal;

int grapesodaTotal;

int creamsodaTotal;

int EndTotal;

int colaCounte= 20;

int rootCounter = 20;

int grapeCounter= 20;

int creamCounter = 20;

string[,] drinkDesc = new string[,]

{

{\"Cola\", \"1.00\",\"20\"},

{\"Root Beer\", \"1.00\", \"20\",},

{\"Lemon Lime\", \"1.00\", \"20\",},

{\"Grape Soda\", \"1.00\", \"20\"},

{\"Cream Soda\", \"1.00\", \"20\"}

};

Drinks vend;

private void ColaPictureBox_Click (object sender, EventArgs e)

{

Vend.drinkname = drinkDesc[0,0];

Vend.drinkcost = drinkDesc[0,1];

Vend.inventory = drinkDesc[0,2];

colaCounter = colaCounter-1;

{

CokeCountLabel.text = colaCounter.ToString();

if(colaCounter < 1)

{

MesssageBox.Show(\"Sorry out of cokes\");

}

colaTotal = colaTotal +1;

cokeTotal = colaTotal * 1;

}

}

private void RootPictureBox_Click(object sender, EvenArgs e)

{

vend.drinkname = drinkDesc[1,0];

vend.drinkcost = drinkDesc[1,1];

vend.inventory = drinkDesc[1,2];

rootCounter = rootCounter-1;

{

RootBeerLabel.text = rootCOunter.ToString();

if(rootCounter < 1)

{

MessageBox.Show(\"sorry out of stock\");

}

rootTotal = rootTotal +1;

rootBeerTotal = rootTotal*1;

}

}

private void exitButton_Click(object sender, EventArgs e)

{

this.CLose();

}

private void LemonPictureBox_Click(object sender, EventArgs e)

{

Vend.drinkname = drinkDesc[2,0];

Vend.drinkcost = drinkDesc[2,1];

Vend.inventory = drinkDesc[2,2];

lemonCountr = lemonCounter - 1;

{

lemonCountlabel.Text = lemonCounter.ToString();

if(lemonCounter <1)

{

MessageBox.Show{@sorry out of stock@);

}

lemonTotal = lemonTotal+1;

lemonlimeTotal = lemonTotal*1;

}

}

private void GrapePictureBox_Click(object sender, EventArgs e)

{

Vend.drinkname = drinkDesc[3,0];

Vend.drinkcost = drinkDesc[3,1];

Vend.inventory = drinkDesc[3,2];

grapeCounter = grapeCounter -1;

{

GrapeCountLabel.Text = grapeCounter.toString();

if(grapeCounter < 1)

{

MessageBox.Show(\"sorry out of stock\");

}

grapeTotal = grapeTotal +1;

grapeSodaTotal = Vend.inventory*Vend.drinkcost;

}

}

private void CreamPictureBox_Click(object sender, EventArgs e)

{

Vend.drinkname = drinkDesc[4,0];

Vend.drinkcost = drinkDesc[4,1];

Vend.inventory = drinkDesc[4,2];

creamCounter = creamCounter -1;

{

creamCountLabel.text = creamCounter.toString();

if(creamCounter < 1)

{

Messagebox.Show(\"sorry out of stock\");

}

creamtotal = creamTotal +1;

creamtotal = creamTotal *1.5;

}

}

private void TotalpictureBox_Click(object sender, EventArgs e)

{

EndTotal = (cokeTotal+rootBeerTotal+lemonlimeTotal+grapeSodaTotal*creamSodaTotal);

Totallabel.text=EndTotal.Tostring(\"c\");

}

}

}

This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let
This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let
This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let
This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let
This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let
This Needs To Be Done In Visual C# Drink Vending Machine Simulator Create an application that simulates a soft-drink vending machine. The application should let

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site