Submission
Due Dates
Your program will ask the user for the number of input values. The program will then accept user input values one-by-one (see example below). The input values will be distinct and >=2. The digits within an input value need not be distinct.
For each input value:
Finally, your program has to print the input value that has the maximum value for count. If none of the input values contain non-prime digits within them, print a line stating, “No non-prime digits in the input values”.
How many input values
> 5
Input Value#1
> 121
121 has 2 non-prime digit(s)
Input Value#2
> 231
231 has 1 non-prime digit(s)
Input Value#3
> 678
678 has 2 non-prime digit(s)
Input Value#4
> 345
345 has 1 non-prime digit(s)
Input Value#5
> 999
999 has 3 non-prime digit(s)
999 has the maximum number of non-prime digits
How many input values
> 3
Input Value#1
> 325
325 has 0 non-prime digit(s)
Input Value#2
> 237
237 has 0 non-prime digit(s)
Input Value#3
> 777
777 has 0 non-prime digit(s)
No non-prime digits in the input values
Player A and Player B play the game of multiplication as specified by the rules below:
Player B randomly generates an integer value in [2, 9] and multiplies the value with the value of P computed in Step 4.
Write a program to implement the multiplication game as per the above rules.
import java.util.Random;
public class Guessing_Game {
public static void main(String[] args) {
Random random = new Random();
int limit = 2 + random.nextInt(999);
System.out.println("N = " + limit);
// Your code here
}
}
N = 25
A randomly selects 3.
P = 3
B randomly selects 2
P = 6.
A randomly selects 6
P = 36.
A wins!
In this program, you will simulate the rolling of two dice. Use the random number generator to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Your program should roll the dice 10000 times. Use an integer array of the appropriate size to tally the number of times each possible sum appears. Display the results.
2 occured 269 times
3 occured 541 times
4 occured 818 times
5 occured 1079 times
6 occured 1446 times
7 occured 1648 times
8 occured 1468 times
9 occured 1109 times
10 occured 800 times
11 occured 552 times
12 occured 270 times
Your program should declare an integer array of input size and take distinct integer input values into it. Finally, the program should output the contents of the array in random order.
Input the size of the array:
> 7
Input Array:
> 1
> 2
> 3
> 4
> 5
> 6
> 7
Random Output: 7 2 3 6 1 5 4
Input the size of the array:
> 7
Input Array:
> 1
> 2
> 3
> 4
> 5
> 6
> 7
Random Output: 1 5 6 3 7 4 2