History, asked by sunitazirange, 10 months ago

write a java program to arrange 3 numbers (input by user)in descending order.
plzzzz its urgent!!!!!!!!!!

Answers

Answered by Anonymous
8

//using the utility process

import java.util.*;

public class Number

{

public static void main(String args[])

{

//using scanner class and it is mendatory for taking input.

Scanner in = new Scanner(System.in);

int a,b,c,d,e,f;

System.out.println("Enter the three numbers");

a=in.nextInt();

b=in.nextInt();

c=in.nextInt();

d=Math.max(a,b,c);

e=Math.min(a,b,c);

f=(a+b+c)-(d+e);

System.out.println("The largest number is"+d);

System.out.println("The second largest number is"+f);

System.out.println("The smallest number is"+f);

}

}

Answered by irakhedkar
2

import java.util.*;

public static void main(String args[]){

Scanner in = new Scanner(System.in);

int arr[] = new int[3];

int tempo = 0;

for(int i = 0; i < 3; i++){

System.out.println("Enter a number");

arr[i] = in.nextInt();

}

for(int i = 0; i < 3; i++){

for(int j = i + 1; j < 3; j++){

if(arr[i]<arr[j]){

tempo = arr[i];

arr[i] = arr[j];

arr[j] = tempo;

}

}

}

Hope this helps,

ira.

Similar questions