Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

third time i post this, always wrong answers!! please include program output sam

ID: 3693232 • Letter: T

Question

third time i post this, always wrong answers!! please include program output sample!

You will creat a new program that simulates the game of lotto using ARRAYS.

How does this work? the user will input 6 numbers (integers), ranging from 1 to 59.

the computer willl randomly pick the winning numbers (6 of them and the "Bonus" number)

in order to win first prize the user must match all of the 6 numbers.

in order to win second prize, the user will must match all of the 6 numbers AND the bonus number.

numbers CANNOT be generated twice, for example 6,18,18,50,52,55 is not valid as 18 appears twice.

winning numbers (via the computer) are always presented in ascending order.

include data validation and echo user input.

ARRAYS must be used in this program.

Explanation / Answer

import java.util.*;

public class HelloWorld
{
public static void main(String args[])
{
    Scanner read=new Scanner(System.in);
    int win[]=new int[6],user[]=new int[6];
    int bonus=0,winbonus=0,count=0;
   System.out.println("Welcome to game of lotto");
   System.out.println("Enter your digits");
   for(int i=0;i<6;i++)
   user[i]=read.nextInt();
   System.out.print("Enter your bonus value: ");
   bonus=read.nextInt();

Random random = new Random();
int Low = 1;
int High = 59;
bonus=random.nextInt(High-Low) + Low;
   win[0]=random.nextInt(High-Low) + Low;
   boolean flag=true;
   int tmp;
   while(count<6)
   {
       int found=0;
       flag=true;
       tmp=random.nextInt(High-Low) + Low;
       for(int i=0;i<count;i++)
       {
           if(tmp==win[i])
           found=1;
       }
       if(found==0)
       {
           win[count]=tmp;
       count++;
       }
    }
    int found=0;
   for(int i=0;i<6;i++)
   {
       if(win[i]!=user[i])
       found=1;
   }
   System.out.println(" Winning nos are");
   for(int i=0;i<6;i++)
    System.out.print(" "+win[i]);
    System.out.println(" Your nos are");
   for(int i=0;i<6;i++)
   System.out.print(" "+user[i]);
   if(found==1)
    System.out.println(" Sorry,your nos dont match with the winning ticket. Try aain next time!!");
   else
   if(found==0 && bonus==winbonus)
    System.out.println(" Congrats!! You have won second prize");
   else
   System.out.println(" Congrats!! You have won first prize");

}
}