Write a program that displays the smallest of five input values that may include duplicate values (e.g., 6, 4, 8, 6, 7). Hint: Review the four solutions in the smallest number case study in this chapter. Consider how easy or hard it would be to modify each of those algorithms to find the smallest of five rather than three values. Then modify the algorithm you consider most appropriate for this problem.

Respuesta :

Answer:

Here the code is given as follows,

Explanation:

Code:-

import java.util.*;

class Chegg {

 

   public static void main(String args[])

   {

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter 5 numbers");

       int arr[]=new int[5];

       int min;

       for(int i=0;i<5;i++)

       {

           arr[i]=sc.nextInt();

       

       }

       min=arr[0];

       for(int i=1;i<5;i++)

       {

           if(arr[i]<min)

           {

               min=arr[i];

           }

       }

       System.out.println(min);

   }

}