1. Define the following functions next to main() and call them from your driver.
ID: 3671185 • Letter: 1
Question
1. Define the following functions next to main() and call them from your driver.
2. Define the following functions…
public static int findMin(int[] input)
Given an array, this function returns the smallest value contained in the array
public i static nt findMax(int[] input)
Given an array, this function returns the largest value contained in the array
3. Define the following functions, using findMin() and findMax()
public static int findRange(int[] input)
Given an array {1,2,20}, this function determines the range of values, inclusive [1,20].
Use findMin() and findMax() to accomplish this.
Explanation / Answer
1.
It is compulsory to calling a main function in the given statement
Without calling the main program will not execute
2.
public static int findMin(int[] input)
We are making this public
and it is a static variable
We are giving the datatype as int for finding the smallest value
We are representing in array form
3.
public static int findMax(int[] input)
We are using this function for calculating largest value
We are giving it in system.out.println so we are using in public static void main
We are also representing in array form
4.
We are using this function for finding the range
public static int findRange(int[] input)
5.
Here the maximum will be 20
and the minimum will be 1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.