0

How to make array list for Lottery game?

When I tried to input duplicate number, program stopped and exited. But the expected output should be - the program must continue to run and ask the user to enter a different number to get the expected result.

17th Nov 2019, 12:05 AM
Jorem Magday
Jorem Magday - avatar
5 odpowiedzi
+ 2
You will have to share your code, or we won’t be able to tell what’s going on
17th Nov 2019, 12:35 AM
Jax
Jax - avatar
0
import java.util.Scanner; import java.util.Random; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; public class Lotto { public static void main(String[] args) { char play_again = 'y'; int[] numbers = new int[49]; int[] six_42 = new int[6]; int[] six_45 = new int[6]; int[] six_49 = new int[6]; int[] lucky_numbers = new int[3]; int[] userNumber = new int[6]; Scanner sc = new Scanner(System.in); int guess1, guess2, guess3, guess4, guess5, guess6; int win_num1, win_num2, win_num3, win_num4, win_num5, win_num6; int prize_six_42 = 1000; int prize_six_45 = 1000; int prize_six_49 = 1000; int prize_lucky_numbers_3 = 800; int prize_lucky_numbers_1 = 800; int i; SimpleDateFormat formatter = new SimpleDateFormat("MM dd yyyy"); Date date = new Date(); while (play_again == 'y') { System.out.println("---------------------------"); System.out.println("*** Welcome to IT Lotto ***"); System.out.println("-------------------
17th Nov 2019, 12:45 AM
Jorem Magday
Jorem Magday - avatar
17th Nov 2019, 12:52 AM
Jorem Magday
Jorem Magday - avatar
0
In sololearn you can only run input once and then resets, this code seems to be very large have you learned about methods
17th Nov 2019, 1:32 AM
D_Stark
D_Stark - avatar