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

Need help with psuedocode public class LotteryApplication2 { public static void

ID: 3831309 • Letter: N

Question

Need help with psuedocode

public class LotteryApplication2 {

public static void main(String[] args){

int NUM_DIGITS = 5;

int[] userDigits = new int[5];
int[] lotteryNumbers = new int[5];
int sameNum = 0;

generateNumbers(lotteryNumbers);
getUserData(userDigits);
sameNum = compareArrays(userDigits, lotteryNumbers);
  
  
  


System.out.println("Lottery numbers: " + lotteryNumbers[0] + " " +
lotteryNumbers[1] + " " + lotteryNumbers[2] + " " + lotteryNumbers[3] +
" " + lotteryNumbers[4] + " ");

System.out.println("Player numbers: " + userDigits[0] + " " + userDigits[1] + " " + userDigits[2] + " " + userDigits[3] + " " + userDigits[4] + " ");
System.out.println("Number of matching digits: " + sameNum);

if (sameNum == 5){
   System.out.println("GRAND PRIZE WINNER YOU WIN $1 MILLION");
   }

if (sameNum == 4){
   System.out.println("4 numbers match you win $500,000");
   }

if (sameNum == 3){
   System.out.println("3 numbers match you win $10,000");
   }

if (sameNum == 2){
   System.out.println("2 numbers match you win $1000");
   }

if (sameNum == 1){
   System.out.println("1 number matches you win $10");
}
if (sameNum ==0){
   System.out.println("No matching numbers better luck next time");
   }


}
public static int generateNumbers(int [] lotteryNumbers){


Random randNum = new Random();

lotteryNumbers[0] = randNum.nextInt(10);
lotteryNumbers[1] = randNum.nextInt(10);
lotteryNumbers[2] = randNum.nextInt(10);
lotteryNumbers[3] = randNum.nextInt(10);
lotteryNumbers[4] = randNum.nextInt(10);

return lotteryNumbers[4];
}

public static int getUserData (int [] userDigits){
Scanner keyboard = new Scanner(System.in);

System.out.print("Pick number 1: ");
userDigits[0] = keyboard.nextInt();
System.out.print("Pick number 2: ");
userDigits[1] = keyboard.nextInt();
System.out.print("Pick number 3: ");
userDigits[2] = keyboard.nextInt();
System.out.print("Pick number 4: ");
userDigits[3] = keyboard.nextInt();
System.out.print("Pick number 5: ");
userDigits[4] = keyboard.nextInt();

return userDigits[4];


}

public static int compareArrays (int [] userDigits,
int [] lotteryNumbers)
{

int sameNum = 0;
for (int i = 0; i < 5; i++){
  
  
  
   if (lotteryNumbers[i] == userDigits[i])
   {
   sameNum++;
   }
}
  
return sameNum;
  
}
}

horrible at pseudocode anyone know what it might be for program? public class LotteryApplication2

Explanation / Answer

This program, is checking the lottery number digits with the user number digits and says how many digits in the user number are same in the lottery number and how much prize money user getting will be displayed.

Initially Public static void main() will call the function generateNumbers()

generatenumbers() will generate a 5 digit number stores in letteryNumbers[5] array

next public static void main() will call the getUserData() function

getUserData will take 5 digits from the user’s keyboard and store it in UserDigits[5] array

Next public static void main() will call the compareArrays() function, which compare the userdigits with lottery number digits counts how many digits are matching and returns the count to sameNum.

Now public static void main() will displays lotter number digits and next lottery number digits

If 5 digits in the lottery number and user number are same then it displays “GRAND PRIZE WINNER YOU WIN $1 MILLION”

If 4 digits in the lottery number and user number are same then it displays “4 numbers match you win $500,000”

If 3 digits in the lottery number and user number are same then it displays “3 numbers match you win $10,000”

If 2 digits in the lottery number and user number are same then it displays “2 numbers match you win $1000”

If 1 digit in the lottery number and user number are same then it displays “1 number matches you win $10”

If 0 digits are matching then it will displays “1 number matches you win $10”

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote