Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago