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

  Problem releated to relationship-inheritance

Grading: For each programming assignment, you are graded by explaining and demoing your code to a TA. You must demo your program BEFORE the next assignment is due, and if you fail to do so, you will automatically lose 50 points! Your job is to con..

  Write prolog code for the predicate in position

What does the predicate pp/1 do and how? Would it matter if the board elements were messed up (not in order)? Would it be possible to write a recursive predicate that does the same operation? Again, would the order of board elements matter?

  Determine decimal value on big-endian machine

A 32-bit word on the little-endian computer has decimal value of 261. Determine its decimal value on big-endian machine?

  Programming tasks use any high-level programming

Programming Tasks Use any high-level programming language you wish for the following programming exercises. Do not call built-in library functions that accomplish these tasks automatically. (Examples are sprintf and sscanf from the Standard C librar..

  The companies are facing various challenges

1. The companies are facing various challenges related to the system integration. The SI is more focused towards constant approach rather than adopting the ways which are much needed in the current scenario. There are services which are not much comp..

  Problem regarding the business intelligence tools

Identify a commercially available or open-source business intelligence tool and the type of business performance information it provides. Do not repeat an example that has been posted by another student.

  Accumulation of large amounts of data from multiple sources

The systematic accumulation of large amounts of data from multiple sources

  Which of the following addresses are not allowed on internet

Which of the following addresses are not allowed on the internet?

  How much memory is required to store picture

A 1024*768 image is displayed, noninterlaced, at a rate of thirty frames per second. If the image is stored with 64k-color resolution, which uses 2 bytes per pixel, how much memory is required to store the picture?

  Ssl web security and system architecture

Discuss the task and write a report. Introduction,SSL Web Security,Background of topic and solutions,Project Requirement,System Architecture,System Design,Client Side implementation.

  Come up with an imaginary peripheral device which you think

Come up with an imaginary peripheral device which you think would be useful in personal or business use. Describe what this device would do.

  What are the drawbacks to so large a minimum packet size

If compatibility were not an issue, how might the specifications be written so as to permit a smaller minimum packet size?

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