
Concept explainers
Write a program to produce an array of integer random numbers. Your
program should find out from the user how many numbers to store. It should then generate and store that many random integers (the random numbers must be between 1 and 999 inclusive). The program should then determine the smallest number, the largest number, and the average of all the numbers stored in the array. Finally, it should print out all the numbers on the screen, five numbers to a line with spaces in between. Once the contents of the array have been printed to screen, display the smallest number, largest number, and average determined previously. You should ensure that your program design in modular.
The Random class of Java library (java.util.Random) implements a random
number generator. To generate random numbers, you construct an object of q the class Random, and then use the method nextInt(n) which returns a number between 0 (inclusive) and n (exclusive). Eg:
import java.util.Random;
.....
Random generator = new Random();
.....
//generate a random number between 0 and 99 (inclusive)
int nextRand = generator.nextInt(100);
Alternatively use Math.random(), which returns a random value
in the range 0.0 to 1.0 (then adjust to the correct range)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images

- Search the web to discover the 10 most common user-selected passwords, and store them in an array. Design a program in Flowgorithm that prompts a user for a password, and continue to prompt the user until the user has not chosen one of the common passwords.arrow_forwardWrite a program where the user enters 10 floating point numbers into an array and it shows the numbers that are greater than the average. Input = 7.5 3.0 4.9 2.8 8.4 6.6 2.4 6.1 3.7 1.5 Output = 7.5 4.9 8.4 6.6 6.1 Input = 2.3 11.76 10.32 12.4 5.91 5.68 9.3 4.6 13.47 10.1 Output = 11.7 10.3 12.4 9.3 13.4 10.1 Requested files main.c 1 Binclude 2 3- int main(O 4 // Write your code here.. return(0);arrow_forward4. Given an integer array of size 10, write a Java program to prompt the user to enter an integer value num and in the output print all numbers in the array greater than num. If no such number is present then print the message "No Results Found." in the output. Given Array: {12,67,45,89,94,56,78, 34, 47, 63}arrow_forward
- Please help me write this Java code for this question I’m having troublesarrow_forwardCreate a Program that asks for 10 integers (Use Arrays). Afterwards, display a navigation menu and perform the following: (1) Display the numbers (2) Display it in reverse order (3) Display the values of even indices (0th, 2nd, 4th, 6th, 8th, ..., 2n) (4) Display the values of odd indices (1st, 3rd, 5th, 7th, 9th,.., 2n+1) (5) Ask for an index k, then rotate array to the right. (6) Ask for an index k, then rotate the array to the left. Sample Input 10 45 15 26 35 25 7 12 8 3 1 10 45 15 26 35 25 7 12 8 3 2 10 45 15 26 35 25 7 12 8 3 3 10 45 15 26 35 25 7 12 8 3 4 10 45 15 26 35 25 7 12 8 3 5 2 10 45 15 26 35 25 7 12 8 3 6 2 Expected Output number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse order 3. Display values of even indices 4. Display values of odd indices 5. Rotate array by k (Forward) 6. Rotate array by k (Backward) choice: 1 10 45 15 26 35 25 7 12 8 3 number: 10 45 15 26 35 25 7 12 8 3 Menu: 1. Display the numbers 2. Display it in reverse…arrow_forwardWrite a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array then display the lowest number, highest number, the total of the numbers, and the average of the numbers. using java different methodsarrow_forward
- I could really use some help with a problem I got for coding. A screenshot showing an example would help.arrow_forwardPrimeAA.java Write a program that will tell a user if their number is prime or not. Your code will need to run in a loop (possibly many loops) so that the user can continue to check numbers. A prime is a number that is only divisible by itself and the number 1. This means your code should loop through each value between 1 and the number entered to see if it’s a divisor. If you only check for a small handful of numbers (such as 2, 3, and 5), you will lose most of the credit for this project. Include a try/catch to catch input mismatches and include a custom exception to catch negative values. If the user enters 0, the program should end. Not only will you tell the user if their number is prime or not, you must also print the divisors to the screen (if they exist) on the same line as shown below AND give a count of how many divisors there are. See examples below. Your program should run the test case exactly as it appears below, and should work on any other case in general. Output…arrow_forwardWrite a program that allows a user to enter any desired amount of student grades, stores the grades in an array, then prints the results to the screen. Then, find the average of the grades.arrow_forward
- Write a program that can be used to gather statistical data about the number of movies college students see in a month. The program should perform the following steps: Ask the user how many students were surveyed. An array of integers with this many elements should then be dynamically allocated.. Allow the user to enter the number of movies each student saw into the array. Calculate and display the total and average of the values entered. Input validation: Do not accept negative numbers for input.arrow_forwardQ1. Write a Java program that performs the following steps: Prompt the user to input two positive integers: firstNum and secondNum (firstNum must be less than secondNum). Output all odd numbers between firstNum and secondNum. Output the sum of all even numbers between firstNum and secondNum. Output the sum of the square of the odd numbers between firstNum and secondNum. Q2. write a Java program to encode a name by creating an array of integers. Write Java method called encodeName that takes a name as a string (without spacing and all lower case) and returns an array of integers of the same size as name whose elements are the number in the alphabet of the corresponding character in name (starting from zero). For example, calling this method with name = “aabed” it should return [0, 0, 1, 4, 3]. Write a printArray method that prints all the elements of an array of integers in one line. Write a main method that calls encodeName and printArray methods to print the array…arrow_forward1. Write a JavaScript program that calls these three methods. a. method 1 should print: 54321 4321 321 21 1 b. method 2 should print: 12345 1234 123 12 1 c. method 3 should create and array and store 10 multiples of 5 and print it out. Use for loop to generate the multiples and then print them out using a second for loop.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





