Java programming ( Count single digits ) Write a program that generates 100 rand
ID: 668892 • Letter: J
Question
Java programming
(Count single digits) Write a program that generates 100 random integers between
0 and 9 and displays the count for each number. (Hint: Use an array of ten integers,
say counts, to store the counts for the number of 0s, 1s, . . . , 9s.)
*8.23 (Game: find the flipped cell) Suppose you are given a 6-by-6 matrix filled with
0s and 1s. All rows and all columns have an even number of 1s. Let the user flip
one cell (i.e., flip from 1 to 0 or from 0 to 1) and write a program to find which
cell was flipped. Your program should prompt the user to enter a 6-by-6 array
with 0s and 1s and find the first row r and first column c where the even number
of the 1s property is violated (i.e., the number of 1s is not even). The flipped cell
is at (r, c). Here is a sample run:
Enter a 6-by-6 matrix row by row:
1 1 1 0 1 1
1 1 1 1 0 0
0 1 0 1 1 1
1 1 1 1 1 1
0 1 1 1 1 0
1 0 0 0 0 1
The flipped cell is at (0, 1)
Explanation / Answer
public class Exercise_07 { static final int SIZE = 100; static final int RANGE = 10; public static void main(String[] args) { int[] randomNumbers = new int[SIZE]; int[] occurrence = new int[RANGE]; // generate random numbers 0-9 for (int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.