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

(Find the Smallest Value ) Write an application that finds the smallest of sever

ID: 3779261 • Letter: #

Question

(Find the Smallest Value ) Write an application that finds the smallest of several integers . Write a program which first asks the user to enter the number of values to enter, then asks for each value , and finally prints out the lowest value of those entered.
What I have so far:

import java.util.Scanner;

public class SmallestValue {

public static void main(String[] args) {

int numbers[] = new int[5];
int lowest;
int highest;

Scanner input = new Scanner(System.in);

for(int c = 0; c < numbers.length; c++){
System.out.print("Please enter a number to enter: ");
int number = input.nextInt();

if (c == 0) {
lowest = number;

} else {
if(number < lowest) {
lowest = number;
}

}

numbers[c] = number;
}


System.out.println("The lowest number is: " + lowest);

}
}

So that should be expected output. Can someone help me with the logic of this program please

Interactive Session v Hide Invisibles Enter the number of integers you are going to enter 6- Enter the 1.of.6. number 789- Enter the 2.of 6. number 123- Enter the 3 of 6. number 456- Enter the .4 of 6. number: 369 Enter the 5.of 6. number 258- Enter the 6 of 6 number: 723- The lowest number is 123- Highlight

Explanation / Answer

import java.util.Scanner;
public class SmallestValue
{
public static void main(String[] args)
{
       int lowest;
       Scanner input = new Scanner(System.in);
       System.out.print("Please enter the number of integers you are going to enter: ");
       int num = input.nextInt();
       int numbers[] = new int[num];
       for(int c = 0; c < num; c++)
       {
           System.out.print("Enter the "+(c+1)+" of "+num+" number: ");
           numbers[c]=input.nextInt();
       }
       lowest=numbers[0];
       for(int c = 1; c < num; c++)
       {
           if(lowest>numbers[c])
               lowest=numbers[c];
       }
       System.out.print("The lowest number is "+lowest);
   }
}