1.
An integer 12310 could be split into two integers, for examples 1 and 2310, or 12 and 310, or 123 and10, or 1231 and 0. If we multiply the corresponding split integers, the results are 1 x 2310 = 2310, 12 x310 = 3720, 123 x 10 = 1230, and 1231 x 0 = 0. Here, 3720 is the largest result of multiplying two splitintegers of 12310.
Write a Java program to read an integer from the user, and print out the largest value of themultiplication of its split integers. In our previous example, the output should be 3720. Some examples:
Input: 10011
The largest output is 1100 = 100*11
Input: 222222
The largest output is 49284 = 222*222
2.When we use the statement int j = (int) (Math.random() * 2), the probability of j=0 equals to theprobability of j=1, which is 0.5. Write a Java method that randomly returns 0 or 1 but with theprobabilities set by a user. For example, when a user set the probability of 0 to 0.2, your method willreturn 1 with probability 0.8. Write a test program that outputs 20 random numbers (0 or 1) accordingto the probability given by the user. For example:
Enter the probability of generating zero: 0.2Output: 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 0 1
Enter the probability of generating zero: 0.01Output: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
An integer 12310 could be split into two integers, for examples 1 and 2310, or 12 and 310, or 123 and10, or 1231 and 0. If we multiply the corresponding split integers, the results are 1 x 2310 = 2310, 12 x310 = 3720, 123 x 10 = 1230, and 1231 x 0 = 0. Here, 3720 is the largest result of multiplying two splitintegers of 12310.
Write a Java program to read an integer from the user, and print out the largest value of themultiplication of its split integers. In our previous example, the output should be 3720. Some examples:
Input: 10011
The largest output is 1100 = 100*11
Input: 222222
The largest output is 49284 = 222*222
2.When we use the statement int j = (int) (Math.random() * 2), the probability of j=0 equals to theprobability of j=1, which is 0.5. Write a Java method that randomly returns 0 or 1 but with theprobabilities set by a user. For example, when a user set the probability of 0 to 0.2, your method willreturn 1 with probability 0.8. Write a test program that outputs 20 random numbers (0 or 1) accordingto the probability given by the user. For example:
Enter the probability of generating zero: 0.2Output: 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 0 1
Enter the probability of generating zero: 0.01Output: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1