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.
- Do you wish to make lottery game selections? Y or y for yes, N or n for no Input from keyboard - Y
- 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
- How many games would you like to play? Input from keyboard - 2
- Thank you! The numbers randomly generated were: 350 100
- The sum of each individually selected number is 9
- 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();
}
}
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..
|