Question: Programming assignment You will be designing / implementing the completion of a Program that simulates the QuickPick function at a local convenience-store when selling Lottery
Programming assignment
- You will be designing / implementing the completion of a Program that simulates the QuickPick function at a local convenience-store when selling Lottery Game Tickets such as
Lotto, MegaMillons, Daily Number, PowerBall, etc.
You will need the services of the already implemented Class called the Randomizer - specifically, the generateInt() method which has the following signature:
/** Returns a random integer value between the values passed in as arguments high and low inclusive of. So invoking generateInt(100, 200) might return 100, or 200 or any value between
*/
int generateInt(int low, int high){ }
- Review the code of the stubbed out edu.cuny.csi.csc330.lab3.LottoQuickPicker
Finish the implementation of this Class given the following requirements reviewed in class:
- Needs to generate 1 or more quick pick game (one by default overridden by an optional command line argument).
- For each game:
- Generate 6 unique numbers between 1 and 59.
- The Class is responsible for displaying the game ticket as described below (see actual example below as well).
- The unique numbers for each game must be sorted in ascending order on the same horizontal line.
- The Game Ticket should display a game specific heading including a date/time.
- Each game will be numbered/indexed 1,2,3, N
- Game numbers will be evenly spaced /formatted. And single digit numbers will be padded with a leading 0.
- The Game Ticket should display both a header and trailer of your own choosing (see general format and sample displayed ticket below).
| LOTTO Jan 2, 2019 10:11am ( 1) 15 18 25 32 37 42 ( 2) 12 28 44 46 55 57 (N) 02 09 19 20 21 29 LAB Assignment 3 CSC330 |
EXTRA CREDIT FEATURE +10 points
| --------------------------------- ------------ LOTTO ------------ Sun Jan 27 19:56:38 EST 2019 ( 1) 15 18 25 32 37 42 ( 2) 12 28 44 46 55 57 ( 3) 16 18 24 27 28 54 ( 4) 08 25 29 38 40 44 ( 5) 05 14 18 29 53 58 ( 6) 31 44 46 50 51 54 ( 7) 08 09 11 14 29 47 Odds of Winning: 1 in 45,057,474 <<<<<< EXTRA CREDIT INFO ----- (c) S.I. Corner Deli ----- --------------------------------- |
- How would you calculate the odds of customer winning a single purchased Lotto Game? Well, what are the odds of picking 6 randomly selected numbers out of a pool of 59 numbers? Research the mathematical solution, and code it in the calculateOdds() method - and display the value returned by this method as shown above.
- NOTE:
- Your solution should work for any game specification not just 6 of 59.
- To get full [10 points] credit, describe your solution in comment block above the calculateOdds() method.
help me following java coding/**
/** * LAB 3 - Lotto QuickPicker Game */ package edu.cuny.csi.csc330.lab3;
import edu.cuny.csi.csc330.util.Randomizer;
public class LottoQuickPicker { // constants specific to current game - BUT NOT ALL GAMES public final static int DEFAULT_GAME_COUNT = 1; private final static String GAME_NAME = "Lotto"; private final static int SELECTION_POOL_SIZE = 59; private final static int SELECTION_COUNT = 6;
public LottoQuickPicker() { init(DEFAULT_GAME_COUNT); } public LottoQuickPicker(int games) { init(games); }
private void init(int games) { /** * * Now what ... START FROM HERE * What additional methods do you need? * What additional data properties/members do you need? */ }
/** * */ public void displayTicket() { /** * display heading * * for i in gameCount * generate selectionCount number of unique random selections in ascending order * * display footer */ // display ticket heading displayHeading(); /** * Display selected numbers */
// display ticket footer displayFooter(); return; } protected void displayHeading() { } protected void displayFooter() { } /** * * @return */ private long calculateOdds() { return 0; }
/** * @param args */ public static void main(String[] args) { // takes an optional command line parameter specifying number of QP games to be generated // By default, generate 1 int numberOfGames = DEFAULT_GAME_COUNT; if(args.length > 0) { // if user provided an arg, assume it to be a game count numberOfGames = Integer.parseInt(args[0]); // [0] is the 1st element! } LottoQuickPicker lotto = new LottoQuickPicker(numberOfGames); // now what lotto.displayTicket();
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
