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

Using a loop, write a program that takes 10 integer values from the keyboard and

ID: 3637594 • Letter: U

Question

Using a loop, write a program that takes 10 integer values from the keyboard and outputs the minimum value of all the values entered.

Explanation / Answer

//Determine Small, Large, Average values for a list of integers 07 08 import java.util.*; 09 10 public class SmLrgAvg 11 { 12 public static void main(String[] args) 13 { 14 Scanner keyboard = new Scanner(System.in); 15 16 System.out.println("Enter in a list of non-negative integers. End the list with a negative integer."); 17 18 int n = 0, count = 0; 19 double largestInteger = 0, smallestInteger = n, sum = 0; 20 while (n >= 0) 21 { 22 n = keyboard.nextInt(); 23 smallestInteger = n; 24 25 if (n >= 0) 26 { 27 sum = sum + n; 28 count = count + 1; 29 } 30 if (n >= largestInteger) 31 largestInteger = n; 32 if (n = 0) 33 smallestInteger = n; 34 } 35 System.out.println("The largest integer is: " + largestInteger); 36 System.out.println("The smallest integer is: " + smallestInteger); 37 System.out.println("The average of your list is: " + sum/count); 38 } 39 40 }
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