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

  Design this function to take a character vector

Design this function to take a character vector with multiple strings

  Word problem involving a quadratic function

Write a word problem involving a quadratic function. How would you explain the steps in finding the solution to someone not in this class?

  What is the function of secondary storage

What is the function of secondary storage? Describe three types of secondary storage media, and describe the advantages and disadvantages of each type.

  Secret life of data in the year

1. As detailed in "The Secret Life of Data in the Year 2020," what does "the secret life of data" refer to?

  Develop a c program

Develop a C program. The program should implement and test the following function: uint countOnes(uint hexNumber); The function will return the number of one bits in hexNumber.

  What variables other than wine could explain the finding

what variables other than wine could explain the finding?

  Which of two alternatives you should pursue

The WBS identifies all of the work that must be done to complete the project

  Customer with attributes customerid

TNB electric want to create a database with the following entities- Customer with attributes CustomerID, CName, CAddress(Street, City, State, ZipCode) and CTelephone- Location with attributes LocationID, Address (Street, City, State, ZipCode) and Typ..

  How did nat help resolve the shortage of ipv4 addresses

It allowed SOHO sites to appear as a single IP address,(and single device), to the Internet even though there may be many devices that use IP addresses on the LAN at the SOHO site

  Display a message for asking your first name

Display a message for asking your first name, and then use your first and last names display a greeting message, e.g. "Hello, John Smith!".

  Cloud computing

Select two (2) organizations in which you are interested, and use the Internet and Strayer Library to research the advantages and disadvantages of cloud computing for the selected organizations. Use the Internet to research the characteristics ..

  Introduction to programming

Many financial experts advise that property owners should insure their homes or buildings for at least 80 percent of the amount it would cost to replace the structure.  Design a modular program that asks the user to enter the replacement cost ..

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