Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Any help would be awesome. This is for Visual Basic also. Exercise from 7.1 Assu

ID: 638713 • Letter: A

Question

Any help would be awesome. This is for Visual Basic also.

Exercise from 7.1

Assume the array nums contains a list of positive integers. In the following exercises, write a Function procedure that calculates the stated value with a For Each loop.

the sum of the numbers in the array

the average of the numbers in the array

the largest even number in the array (If there are no even numbers in the array, the Function procedure should return 0.)

the smallest number in the array

the number of two-digit numbers in the array

the number of even numbers in the array

Identify the errors.

Dim nums(3) As Integer = {1, 2, 3, 4}

Dim nums( ) As Integer = IO.File.ReadAllLines(

Explanation / Answer

public static void main(String[] args){ int total = 0; // sum int largest = Integer.MIN_VALUE; // highest int lowest = Integer.MAX_VALUE; // lowest int count = 0; // how many nums enters int average; // average int number = 0; Scanner scanner = new Scanner(System.in); while(true){ if (number < 0) break; System.out.println("Enter a number:"); int number = scanner.nextInt(); // for every number input, increase count by one count++; // freebie code - complete the reamining [your code here]'s // for every number increase total by number [your code here] // if number is greater than largest, largest equals number [your code here] // if number is less than lowest, lowest = number [your code here] } average = total / count; System.out.println("Total input numbers: " + count); System.out.println("Sum of input number: " + sum); System.out.println("Highest number: " + highest); System.out.println("Lowest numer: " + lowest); System.out.println("Average: " + average); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote