Java program to simulate a pick

Assignment Help Basic Computer Science
Reference no: EM131088814

Assignment:

Write a Java program to simulate a pick 3, 4 or 5 lottery drawing. A lottery game of this type will draw values between 0 and 9. You should use the Math.Random() or the java.util.Random() class to generate the values in the lottery drawing. The program should prompt the user for which lottery game they want to play (pick 3 or pick 4 or pick 5). The program should also ask how many times they want to play the game. The output should show the numbers picked for each game and it should sum each individual number selected into a total of all numbers. For example, if a user of the program made a selection to randomly draw 2 three digit numbers (as in the example shown below) the sum would be 3 + 5 + 0 + 1 + 0 + 0 = 9. Here is an example of what a run of your code should produce.

  1. Do you wish to make lottery game selections? Y or y for yes, N or n for no Input from keyboard - Y
  2. Which lottery game do you want to play (Enter 3 for pick-3, 4 for pick-4, 5 for pick-5) Input from keyboard - 3
  3. How many games would you like to play? Input from keyboard - 2
  4. Thank you! The numbers randomly generated were: 350 100
  5. The sum of each individually selected number is 9
  6. Be sure to use at least two classes and at least one constructor method in your answer. Also present runs for all three types of games. Be sure to have loop logic that allows the user to choose to stop playing.

Here's what I created but it's not complete, I need to split it into two classes and have contractor as well as have a loop logic.

import java.util.Scanner;

public class LotteryGame {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int lotteryGaming;

int noOfGame;

int randomNo;

int lotteryNumber;

int sum = 0;

System.out.print("Which lottery game do you want to play (Enter 3 for pick-3, 4 for pick-4 or 5 for pick-5? ");

lotteryGaming = scanner.nextInt();

System.out.print("How many games would you like to play? ");

noOfGame = scanner.nextInt();

System.out.println("Thank you! The numbers selected were: ");

for (int i = 0; i < noOfGame; i++) {

lotteryNumber = 0;

for (int j = 0; j < lotteryGaming; j++) {

randomNo = (new java.util.Random()).nextInt(10);

lotteryNumber = (lotteryNumber * 10) + randomNo;

System.out.print(randomNo + " ");

sum += randomNo;

}

System.out.println();

}

System.out.println("The sum for all numbers picked was: " + sum);

scanner.close();

}

}

Reference no: EM131088814

Questions Cloud

Total estimated externality cost being borne by society : Suppose there is a negative externality associated with wheat production. The costs that it imposes on society from water quality and soil erosion issues are estimated to be $1.50 higher per bushel than the private costs reflected in our supply funct..
Calculate the expected one year interest rate : Suppose the expectations hypothesis of the term structure holds. Calculate the expected one year interest rate, one year from 3/7/2016. Calculate the expected five year rate expected five years from 3/7/2016
Determine its provit maximizing level of exports : Consider a firm in some foreign country producing a good as a monopoly. Its export demand function is given by Q=40- .5p. Its Total Cost function is given by TC=150+8Q, a) Determine its provit maximizing level of exports, and the export price the fir..
Current real and usd exchange rate : The current annual US inflation rate is 3 percent and the current Brazilian annual inflation rate is about 10 percent. Given the current Real/USD exchange rate (3.65) predict the real/USD exchange rate a year from now using relative PPP:
Java program to simulate a pick : Write a Java program to simulate a pick 3, 4 or 5 lottery drawing. A lottery game of this type will draw values between 0 and 9. You should use the Math.Random() or the java.util.Random() class to generate the values in the lottery drawing.
Demand and supply of perfectly competitive industry : Draw a graph (hand-drawn is acceptable) that illustrates the demand and supply of a perfectly competitive industry. the producer surplus if the industry is a monopoly that engages in perfect price discrimination. Does a deadweight loss exist if the i..
Standard vga graphics adapter : Neither of these resolutions solves the problem. You notice the label on the Envision monitor says its native resolution is 1680 x 1050. Device Manager reports the display adapter to be a Standard VGA Graphics Adapter. What could be causing this p..
Using an indifference curve and budget line analysis : Twin sisters Rose and Iris each have $100 to spend on flowers (X) and all other goods (Y). Flowers cost $2 each, and all other goods (AOG) have a composite price of $1 each. Assume that their preferences are represented by convex indifference curves...
Identify errors or omissions and provide suggestions : In 125 to 200 words each, respond to at least two classmates. In each response, address all questions and concerns with clear and concise information and advice. Then, analyze your classmate's proposed argument structure and describe why the argum..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd