. In this java program, explain everyline of this code. Source Code: import java.util.*; public class Casino { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Random random = new Random(); int[] arr = new int[2]; int win =0; for(int i=0;i<2;i++) { arr[i] = random.nextInt(5); } System.out.println("\n######################## CASINO ########################"); System.out.println("\n******************** Guess the two numbers *******************"); System.out.print("The first number : "); int first = scan.nextInt(); System.out.print("The second number : "); int second = scan.nextInt(); if(first==arr[0] && second==arr[1]){ win = 1000; } else if(first==arr[1] && second==arr[0]){ win = 500; } else if(first==arr[0] || second==arr[1] || first==arr[1] || second==arr[0]){ win = 50; } if(win > 0){ System.out.println("Congratulations, You have won " + win + " pesos."); } else{ System.out.println("Better Luck Next Time."); } } }
2. In this java program, explain everyline of this code.
Source Code:
import java.util.*;
public class Casino {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Random random = new Random();
int[] arr = new int[2];
int win =0;
for(int i=0;i<2;i++) {
arr[i] = random.nextInt(5);
}
System.out.println("\n######################## CASINO ########################");
System.out.println("\n******************** Guess the two numbers *******************");
System.out.print("The first number : ");
int first = scan.nextInt();
System.out.print("The second number : ");
int second = scan.nextInt();
if(first==arr[0] && second==arr[1]){
win = 1000;
}
else if(first==arr[1] && second==arr[0]){
win = 500;
}
else if(first==arr[0] || second==arr[1] || first==arr[1] || second==arr[0]){
win = 50;
}
if(win > 0){
System.out.println("Congratulations, You have won " + win + " pesos.");
}
else{
System.out.println("Better Luck Next Time.");
}
}
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









