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
Q2/find the transfer function C/R for the system shown in the figure Re ད
Please original work select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project Please cite in text references and add weblinks
Please original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinks

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