write a program in java what will show the greater number among three numbers use method
Answers
Answer:
Take two integer variables, say A, B& C
Assign values to variables
If A is greater than B & C, Display A is the largest value
If B is greater than A & C, Display B is the largest value
If C is greater than A & B, Display A is the largest value
Otherwise, Display A, B & C are not unique values
Example
import java.util.Scanner;
public class LargestOfThreeNumbers {
public static void main(String args[]){
Scanner sc =new Scanner(System.in);
System.out.println("Enter 1st number :");
int a = sc.nextInt();
System.out.println("Enter 2nd number :");
int b = sc.nextInt();
System.out.println("Enter 3rd number :");
int c = sc.nextInt();
if ( a > b && a > c ){
System.out.println("Largest number is ::"+ a);
}else if ( b > a && b > c ){
System.out.println("Largest number is ::"+ b);
}else if ( c > a && c > b ){
System.out.println("Largest number is ::"+ c);
}else{System.out.println("Cnnot validate");
}
}
}
Enter 1st number :
2
Enter 2nd number :
66
Enter 3rd number :
8
Largest number is ::66
Explanation:
Mark me brainliest and follow me
Mark me brainliest and follow me hope it helps you