Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication9;
- import java.util.ArrayList;
- import java.util.Random;
- import java.util.Scanner;
- /**
- *
- * @author jrowley
- */
- public class JavaApplication9 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner input = new Scanner(System.in);
- // System.out.print("Enter your name:\t");
- // String yourName = input.nextLine();
- int costOfPanel = 2;
- int lottoPanels = 1;
- do {
- System.out.printf("Hi Pick number of Panels (1-6)\t");
- lottoPanels = input.nextInt();
- } while (lottoPanels > 6 || lottoPanels < 1);
- int numberOfQuickPicks = 0;
- do {
- System.out.printf("Hi number of quickPicks (1-%d)\t", lottoPanels);
- numberOfQuickPicks = input.nextInt();
- } while (numberOfQuickPicks > lottoPanels || numberOfQuickPicks < 0 );
- for (int i = 0; i < numberOfQuickPicks; i++) {
- generateLotteryPanelQP();
- }
- for (int i = 0; i < lottoPanels-numberOfQuickPicks; i++) {
- System.out.println("manual entry required");
- }
- int totalCost = costOfPanel* lottoPanels;
- System.out.printf("Price of Lottery is %d\t", totalCost);
- }
- public static void generateLotteryPanelQP() {
- ArrayList<Integer> listOfNumbers = new ArrayList<>();
- // create instance of Random class
- Random rand = new Random();
- for (int i = 0; i < 6; i++) {
- int randomNumber = rand.nextInt(50);
- while (listOfNumbers.contains(randomNumber)) {
- randomNumber = rand.nextInt(50);
- }
- // listOfNumbers.set(i,randomNumber);
- listOfNumbers.add(randomNumber);
- }
- System.out.print("You got: ");
- for (Integer i : listOfNumbers) {
- System.out.printf("%d\t", i);
- }
- System.out.print("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement