Question
Complete the JAVA code below to sum all the values above a given input integer in the created array of random values. For example, if
Complete the JAVA code below to sum all the values above a given input integer in the created array of random values.
For example, if the array is created as [34, 14, 12, 8, 7, 90, 56, 20] and the input minimum value is 50 then the output of the program should be 146 (because the only values above 50 in the array are 90 and 56 and 90+56=146).
Starter Code:
import java.util.*; //import Scanner, Random, and Arrays classes
public class SumAbove { public static void main(String[] args) { //create a Scanner to get the seed for the random number generator Scanner scnr = new Scanner(System.in); int seed = scnr.nextInt(); Random rand = new Random(seed); //ask for the input "minimum" value to search with System.out.println("Enter a positive integer between 1-100 to search above:"); int minVal = scnr.nextInt(); //create an array of random integers (1-100) //the length of the array will also be randomly determined (1-30) int[] arr = new int[rand.nextInt(100)+1]; for (int i=0; i } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started