Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Visual C# chapter 8 programming problem 11 I can not seem to get it to display the correct dollar amount, drink left amount or the

Visual C# chapter 8 programming problem 11 I can not seem to get it to display the correct dollar amount, drink left amount or the total sales. Here is what I have so far

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 Drink_Vending_Machine { struct Drinks { public string drinkName; public double drinkCost; public int no_Of_Drinks_In_Machine; } public partial class DrinkVendingMachine : Form { double total = 0.00; Drinks[] Drink = new Drinks[5]; public DrinkVendingMachine() { InitializeComponent(); } private void DrinkVendingMachine_Load_1(object sender, EventArgs e) { Drink[0].drinkName = "Cola"; Drink[0].drinkCost = 1.00; Drink[0].no_Of_Drinks_In_Machine = 20;

Drink[1].drinkName = "Root Beer"; Drink[1].drinkCost = 1.00; Drink[1].no_Of_Drinks_In_Machine = 20;

Drink[2].drinkName = "Lemon Lime"; Drink[2].drinkCost = 1.00; Drink[2].no_Of_Drinks_In_Machine = 20;

Drink[3].drinkName = "Grape Soda"; Drink[3].drinkCost = 1.50; Drink[3].no_Of_Drinks_In_Machine = 20;

Drink[4].drinkName = "Cream Soda"; Drink[4].drinkCost = 1.50; Drink[4].no_Of_Drinks_In_Machine = 20;

ColaPriceLabel.Text = Drink[0].drinkCost.ToString("c"); RootBeerPriceLabel.Text = Drink[1].drinkCost.ToString("c"); LemonLimePriceLabel.Text = Drink[2].drinkCost.ToString("c"); GrapeSodaPriceLabel.Text = Drink[3].drinkCost.ToString("c"); CreamSodaPriceLabel.Text = Drink[4].drinkCost.ToString("c");

ColaTextBox.Text = 20.ToString(); RootBeerTextBox.Text = 20.ToString(); LemonLimeTextBox.Text = 20.ToString(); GrapeSodaTextBox.Text = 20.ToString(); CreamSodaTextBox.Text = 20.ToString(); TotalTextBox.Text = 0.00.ToString(""); } private void ColaPictureBox_Click(object sender, EventArgs e) { if (Drink[0].no_Of_Drinks_In_Machine

private void DrinkVendingMachine_Load(object sender, EventArgs e) {

}

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

image text in transcribed

This is the design code

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Drink Vending Machine Select a Drink S0.00 S0.00 Root Beer COLA Drinks Left Drinks Left S0.00 S0.00 Lemon Lime Grape Soda Drinks Left Drinks Left S0.00 Total Sales: ream Drinks Left Soda Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago