Computer Science, asked by sneha47242, 10 months ago

write a program in Java to input 3 numbers and find the largest and smallest number using math.max and math. min function​

Answers

Answered by tanupriyatommy
14

Answer:

import java.util.Scanner;

public class LargestSmallest {

public static void main(String [] args) {

 Scanner in = new Scanner(System.in);

 System.out.println("Enter first number: ");

 int n1 = in.nextInt();

 System.out.println("Enter second number: ");

 int n2 = in.nextInt();

 System.out.println("Enter third number: ");

 int n3 = in.nextInt();

       in.close();

   int largest = Math.max(n1, Math.max(n2, n3));

   System.out.printf("Largest : %d", largest);

       System.out.printf("\n");

   int smallest = Math.min(n1, Math.min(n2, n3));

   System.out.printf("Smallest : %d", smallest);

}

}

Explanation:

Output :

Enter first number:  

>>>34

Enter second number:  

>>>56

Enter third number:  

>>>25

Largest : 56

Smallest : 25

Answered by abhisheksingh85385
4

Answer:

above answer is correct

mark me as a Brainlist

Similar questions