Saturday 25 April 2020

DISPLAYING INTEGERS IN NON-DECREASING ORDER USING JAVA LANGUAGE

Q-37- Write a java program that prompts the user to enter three integers and display the integers in non-decreasing order. 

INPUT :
import java.util.Scanner;

public class NCM {

public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc=new Scanner(System.in);
int a ,b ,c;
System.out.println("Enter Three Integers :");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
int Max=Math.max(a,Math.max(b,c));
int Min=Math.min(a,Math.min(b,c));
int Median=a+b+c-(Max+Min);
System.out.println("Display The Integer In Non-decreasing Order :"+Min+" "+Median+" "+Max);

}


}

OUTPUT :
Enter Three Integers :
2 4 3

Display The Integer In Non-decreasing Order :2 3 4



No comments:

Post a Comment