Write a java program to find the Max or Largest number and Min or smallest number between two numbers by taking user input. Display the output of a program.
Answers
Answer:
I hope it will help you
Explanation:
Following are the program is given below
Output:
Please enter the first number:
87
Please enter the second number:
65
Please enter the third number:
34
Greatest Number:87
Smallest Number:34
Explanation:
import java.util.*; // import package
public class Main
{
public static void main(String args[]) // main class
{
Scanner sc3= new Scanner(System.in); // creating the object of scanner class
System.out.println("Please enter the first number:");
int a1= sc3.nextInt(); // taking input by user
System.out.println("Please enter the second number:");
int a2= sc3.nextInt(); // taking input by user
System.out.println("Please enter the third number:");
int a3= sc3.nextInt(); // taking input by user
int t1=Math.max(a1,a2); // find the maximum number between the two
System.out.println("Greatest Number:" +Math.max(t1, a3)); // print the //greatest number
int t2=Math.min(a1,a2); // find the mainimum number between the two
System.out.println("Smallest Number:" +Math.min(t2, a3)); // print the //smallest number
}
}