Question: Java Code: Complete the code below to sum all the values above a given input integer in the created array of random values. For example,

Java Code:

Complete the 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!