1.

Write a program to input three numbers and display the smallest sample input 65,41,98 using Java input scanner class​

Answer»

en problem is solved using LANGUAGE - Java.import java.util.*; public class Min{    public static void main(STRING args[]){        Scanner sc=new Scanner(System.in);        int a,b,c,min;        System.out.print("Enter first number: ");        a=sc.nextInt();        System.out.print("Enter second number: ");        b=sc.nextInt();        System.out.print("Enter third number: ");        c=sc.nextInt();        sc.close();        min=Math.min(a,Math.min(b,c));        System.out.println("Smallest Number: "+min);      } }The Math.min() returns the minimum of two numbers. Here, we have asked the USER two enter three numbers. At first, we will FIND the minimum value of two numbers. Then we will compare the minimum value with the third number. Therefore, we get the smallest number.In this way, the problem is solved.See attachment for output.



Discussion

No Comment Found