In JAVA, write a program that generates 10 random numbers between 0 and 9. Use count arrays for each number.
A sample output would be:
The 10 random numbers are: 5 7 1 9 0 0 1 2 3 4
0 occurs 2 times
1 occurs 2 times
2 occurs 1 time
3 occurs 1 time
4 occurs 1 time
5 occurs 1 time
6 occurs 0 times
7 occurs 1 time
8 occurs 0 times
9 occurs 1 time
import java.util.Scanner;
import java.util.Random;
public class CountNum {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Random r = new Random();
int [] num = new int[100];
int [] count = new int[100];
int i,temp = 0;
int max=9,min=0;
//Initialize num[] array with user input
for(i=0; i <10; i++){
num[i] = r.nextInt((max - min) + 1) + min;
}
System.out.print("The 10 random numbers are: ");
for( i=0;i<10;i++)
{
System.out.print(num[i]+" ");
}
System.out.println();
for(i = 0; i < num.length; i++){
temp = num[i];
count[temp]++;
}//end of for looop
for(i=1; i < count.length; i++){
if(count[i] > 0 && count[i] == 1){
System.out.printf("%d occurs %d time\n",i, count[i]);
}
else if(count[i] >=2){
System.out.printf("%d occurs %d times\n",i, count[i]);
}
}//end of for loop
}//end of main
}//end of CountOccurrenceOfNumbers

In JAVA, write a program that generates 10 random numbers between 0 and 9. Use count...
Problem: Write a program that generates random numbers between 1 and 10 and fill an array of size 20 with them. Have your program sort the array then output in order the number of occurrences of each random number generated. Use the STL sort function to sort your array. How to use the STL sort: #include <algorithm> ... int a[20] ... sort(a,a+20); Example Output: This program generates random numbers and tabulates the results Original List Sorted: a[ 0] 1 a[...
Using Python, Lists: Write a program that randomly generates 1000 numbers between 0 and 9 and counts the count of each number. The output should have this form: 3 occurs 5 times 5 occurs 1 time Notice that if there is more than 1. The word times is used and if there is only 1, the word times is used.
please write in python
Write a program that asks for beginning and ending number. The program generates a set of 20 random numbers between the numbers and displays a count of each number generated. Sample output Enter starting and ending number separated by comma: 5, 25 5 occurs 2 times 7 occurs 1 time 8 occurs 1 time 10 occurs 2 times 12 occurs 1 time 13 occurs 2 time 15 occurs 5 times 16 occurs 1 time 20 occurs...
(Count occurrence of numbers) Write a program that reads some integers between 1 and 100 and counts the occurrences of each. Here is a sample run of the program: Enter integers between 1 and 100: 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1 time 23 occurs 1 time 43 occurs 1 time 2 5 6 5 4 3 23 43 2 Note that if a number occurs more than...
*IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list of ten integers, say counts, to store the counts for the number of 0s, 1s, ..., 9s.) Rubric 5 pts: Proper use of list to count occurrences of numbers 5 pts: Proper calculations of counts 5 pts: Proper output Note: No software dev plan or UML required
C++ language Write a program that 1. generates a random integer between 100 and 1000, call the number N 2. reads a file name from the keyboard 3. opens a file for output using the file name from step 2 4. generates N random numbers between 1 and 100 and writes them to the file from step 3 5. closes the file 6. opens the file from steps 3, and 4 for input 7. reads the numbers from the file...
4. Write a program that generates one hundred random integers
between 0 and 9 and displays the count for each number. (Hint: Use
rand()%10 to generate a random integer between 0 and 9. Use an
array of ten integers, say counts, to store the counts for the
number of 0’s, 1’s,…..,9’s.)
this program kinda works but i cant figure out why its making
more than 100 random numbers
ls) [*] test2.cpp test3.cpp #include<stdio.h> #include<stdlib.h> int main() 4 { int a[14],is...
Write a C program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.)
Hello Sir, I need help with Java. Here is the problem below. Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header: public static String convertMillis(long millis) For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, and convertMillis(555550000) returns the string 154:19:10. Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1...
Write a C++ program that generates a random number from 0 to 9. It will then prompt the user to guess the random number it generated. Your program stops if the user guesses the right number. (Use the cout function to display the random number the computer generates so that you can determine if your code actually works). SAMPLE OUTPUT Random number = 8 Guess a number in the range [0,9]: 1 Too low Guess a number in the range...