Starting Out With Visual C# (5th Edition)
Starting Out With Visual C# (5th Edition)
5th Edition
ISBN: 9780135183519
Author: Tony Gaddis
Publisher: PEARSON
Question
100%
Book Icon
Chapter 9, Problem 2PP
Program Plan Intro

Drink vending machine simulator

Program plan:

Design the form:

  • Place an eighteen label box controls on the form, and change its name and properties.
  • Place a five picture box control on the form, and change its name and properties to display the images.
  • Place a six panel controls on the form, and change its name and properties.
  • Place a one command button control on the form, and change its name and properties to exit the application.

In code window, write the code:

Program.cs:

  • Include the required libraries.
  • Define the namespace “VendingMachine”.
    • Define a class “Program”.
      • Define a constructor for the class.
      • Define required functions to run “Form1”.

Form1.cs:

  • Include the required libraries.
  • Define namespace “VendingMachine”.
    • Define the structure with name “DrinkEntery”.
    • Define a class “Form1”.
    • In updateData() method,
      • Declare the required variables.
      • When user selects a drink, the application decrement “1” from the selected drink quantity.
      • The cost is added to total sales and it is displayed into label box.
    • In pictureBox1_Click() method,
      • Set the index value as “0” and call the updateData() method to perform this drink vending machine simulation.
    • In pictureBox2_Click() method,
      • Set the index value as “1” and call the updateData() method to perform this drink vending machine simulation.
    • In pictureBox3_Click() method,
      • Set the index value as “3” and call the updateData() method to perform this drink vending machine simulation.
    • In pictureBox4_Click() method,
      • Set the index value as “2” and call the updateData() method to perform this drink vending machine simulation.
    • In pictureBox5_Click() method,
      • Set the index value as “4” and call the updateData() method to perform this drink vending machine simulation.
    • In btnExit() method,
      • Close the application.

Form Design:

View the Form Design in IDE.

Starting Out With Visual C# (5th Edition), Chapter 9, Problem 2PP

Set the Form Control properties in Properties window as follows:

ObjectPropertySetting
Form1TextProgram8_11
label1TextSelect a Drink
label2Text$1.00
label3TextDrinks Left:
label4Text$1.00
label5TextDrinks Left:
label6Text$1.50
label7TextDrinks Left:
label8Text$1.00
label9TextDrinks Left:
label10TextTotal Sales
label11Text$1.50
label12TextDrinks Left:
lblResultText$0.00
colaText20
rootbeerText20
grapesodaText20
lemonlimeText20
creamsodaText20
pictureBox1ImageSelect Resource
pictureBox2ImageSelect Resource
pictureBox3ImageSelect Resource
pictureBox4ImageSelect Resource
pictureBox5ImageSelect Resource
panel1Text(Empty)
panel2Text(Empty)
panel3Text(Empty)
panel4Text(Empty)
panel5Text(Empty)
panel6Text(Empty)
btnExitTextExit
  • Add eighteen label box controls to the form from Toolbox.
  • Add five picture box controls to the form from Toolbox.
  • Add six panel controls to the form from Toolbox.
  • Add one command button control to the form from Toolbox.

Blurred answer
Students have asked these similar questions
.NET Interactive Solving Sudoku using Grover's Algorithm We will now solve a simple problem using Grover's algorithm, for which we do not necessarily know the solution beforehand. Our problem is a 2x2 binary sudoku, which in our case has two simple rules: •No column may contain the same value twice •No row may contain the same value twice If we assign each square in our sudoku to a variable like so: 1 V V₁ V3 V2 we want our circuit to output a solution to this sudoku. Note that, while this approach of using Grover's algorithm to solve this problem is not practical (you can probably find the solution in your head!), the purpose of this example is to demonstrate the conversion of classical decision problems into oracles for Grover's algorithm. Turning the Problem into a Circuit We want to create an oracle that will help us solve this problem, and we will start by creating a circuit that identifies a correct solution, we simply need to create a classical function on a quantum circuit that…
.NET Interactive Solving Sudoku using Grover's Algorithm We will now solve a simple problem using Grover's algorithm, for which we do not necessarily know the solution beforehand. Our problem is a 2x2 binary sudoku, which in our case has two simple rules: •No column may contain the same value twice •No row may contain the same value twice If we assign each square in our sudoku to a variable like so: 1 V V₁ V3 V2 we want our circuit to output a solution to this sudoku. Note that, while this approach of using Grover's algorithm to solve this problem is not practical (you can probably find the solution in your head!), the purpose of this example is to demonstrate the conversion of classical decision problems into oracles for Grover's algorithm. Turning the Problem into a Circuit We want to create an oracle that will help us solve this problem, and we will start by creating a circuit that identifies a correct solution, we simply need to create a classical function on a quantum circuit that…
Answer two JAVA OOP problems.

Chapter 9 Solutions

Starting Out With Visual C# (5th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education