Ask Question
21 November, 02:30

5-11) (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.

+5
Answers (1)
  1. 21 November, 04:35
    0
    import java. util. Arrays;

    import java. util. Scanner;

    public class num4 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("How many numbers? ");

    int n = in. nextInt ();

    int []intArray = new int[n];

    //Entering the values

    for (int i=0; i
    System. out. println ("Enter the numbers");

    intArray[i]=in. nextInt ();

    }

    System. out. println (Arrays. toString (intArray));

    int min = intArray[0];

    for (int i = 0; i
    if (min>intArray[i]) {

    min = intArray[i];

    }

    }

    System. out. println ("The Minimum of the numbers is "+min);

    }

    }

    Explanation:

    Using Java programming language Prompt the user for the number of values Using Scanner class receive and store in a variable Create an array of size n Using an for loop continuously ask the user to enter the integers Print the array of integers Using another for loop with an if statement, find the smallest element in the array of numbers Output the the smallest number
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “5-11) (Find the Smallest Value) Write an application that finds the smallest of several integers. Write a program which first asks the user ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers