EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
Chapter 5, Problem 2GZ
Program Plan Intro

Lottery game application

Program plan:

  • Import necessary package.
  • Create a class “Lottery”,
    • Define the method “main ()”,
      • Declare and initialize the necessary variables.
      • Generate the three random numbers.
      • Combine three random numbers into a single three digit number.
      • Get the first digit entered into the first dialog box.
      • Assign the integer value returned form the method “parseInt()”.
      • Get the second digit entered into the second dialog box.
      • Assign the integer value returned form the method “parseInt()”.
      • Get the third digit entered into the third dialog box.
      • Assign the integer value returned form the method “parseInt()”.
      • Check whether the first, second and third digit is equal to the first, second and third random number generated respectively,
        • If it is true, set the match count to “4”.
      • Otherwise, check whether the first digit is equal to the first random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the first digit is equal to the second random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the first digit is equal to the third random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Check whether the second digit is equal to the first random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the second digit is equal to the second random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the second digit is equal to the third random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Check whether the third digit is equal to the first random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the third digit is equal to the second random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Otherwise, check whether the third digit is equal to the third random number generated,
        • If it is true, increment the match count by “1”.
        • Set the first random value to “99”.
      • Check whether the match count is “4”,
        • If it is true,set the highest winning.
      • Otherwise, check whether the match count is “3”,
        • Set the second best winning.
      • Otherwise, check whether the match count is “2”,
        • If it is true, set the third best winning.
      • Otherwise, check whether the match count is “1”,
        • If it is true, set the low winning.
      • Otherwise, set the winning to “0”.
      • Display the output message in dialog box.

Blurred answer
Students have asked these similar questions
Create an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)• If one player chooses…
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/2 mv2In 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.
Write a tkinter application that asks the user to create their own pizza. First, they should enter their name. Then, allow them to pick one of three crusts (thin, regular, deep dish), one of three sauces (Regular, BBQ, Alfredo), and any number of 3 toppings (Pepperoni, Olives, Mushroom). They should also pick if they want a small, medium, or large pizza. When the submit button is clicked, calculate the total cost ($10 base price, $0.50 for each topping, and $1.50 for each increase in size larger than small).  Once the total is calculated, display a messagebox that thanks the user (by name) for their order and prints out the total cost.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
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
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY