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

SLOT MACHINE SIMULATION

Program plan:

  • Design the page.
    • Add title to the form as “Slot Machine”.
    • Place three picture box controls in the form.
    • Place a label control and edit its text property as “Amount Inserted: $”.
    • Place two buttons and edit their text property as “Spin” and “Exit” respectively.
  • In the code window, write the code to:
    • If amount is inserted then execute the form.

Form design:

  • Open Microsoft Visual Studio 2010.
  • Select C# and click Windows Forms Application.
  • Name the project as Slot_Machine.
  • Store the file in D:\Clearly C#\ Slot_Machine.
  • The crated project displayed with a form with the name of Form1.
  • Select the Form1 and add the necessary components.
  • In property window, change the Form name and add changes for Form elements properties.
  • Click the File menu->Save All.

View of the form design in the IDE:

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

The form control properties in the properties window are as follows:

ObjectPropertySetting
Form1TextSlot Machine
pictureBox1ImageLocation of the image
pictureBox2ImageLocation of the image
pictureBox3ImageLocation of the image
label1TextAmount inserted: $
button1TextSpin
button2TextExit
  • Add three picture box control in the form.
  • Add a label control to display the amount inserted.
  • Add the button control spin to execute the slot machine.
  • Add the button control exit to stop the execution the program.

Blurred answer
Students have asked these similar questions
Dice Simulator Create an application that simulates rolling a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use PictureBox controls to display the dice. (In the Student Sample Programs, in the Chap05 folder, you will find six images named Die1.bmp, Die2.bmp, Die3.bmp, Die4.bmp, Die5.bmp, and Die6.bmp that you can use in the PictureBoxes.)
Kinetic Energy In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy: KE =1/2mv2 In the formula KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second. Create an application that allows the user to enter an object’s mass and velocity and then displays the object’s kinetic energy. The application should have a method named KineticEnergy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The method should return the amount of kinetic energy that the object has.
Slot Machine SimulationA slot machine is a gambling device that the user inserts money into and then pulls a lever (or presses a button). The slot machine then displays a set of random images. If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user. Create a program that simulates a slot machine. When the program runs, it should do the following: Asks the user to enter the amount of money he or she wants to enter into the slot machine. Instead of displaying images, the program will randomly select a word from the following list: Cherries, Oranges, Plums, Bells, Melons, Bars To select a word, the program can generate a random number in the range of 0 through 5. If the number is 0, the selected word is Cherries; if the number is 1, the selected word is Oranges; and so forth. The program should randomly select a word from this list three times and display all three of the words. If none of the randomly selected words match, the…

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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,