. import java.util.Scanner; public class Main{ public static void main (String args[]){ Scanner scan=new Scanner(System.in); System.out.print("Enter first number\n"); int num1=scan.nextInt(); System.out.print("Enter second number\n"); int num2=scan.nextInt(); System.out.print("Enter Third number\n"); int num3=scan.nextInt(); findLargest(num1,num2,num3); } static void findLargest(int num1,int num2, int num3){ if(num1>=num2 && num1>=num3){ System.out.println(num1+" is the greatest number"); } else if(num2>=num1 && num2>=num3){ System.out.println(num2+" is the greatest number"); } else{ System.out.println(num3+" is the greatest number"); } 1. Embed your method in a complete program that requests for three variables all of the types int and displays the conditions explained in the code above.
. import java.util.Scanner;
public class Main{
public static void main (String args[]){
Scanner scan=new Scanner(System.in);
System.out.print("Enter first number\n");
int num1=scan.nextInt();
System.out.print("Enter second number\n");
int num2=scan.nextInt();
System.out.print("Enter Third number\n");
int num3=scan.nextInt();
findLargest(num1,num2,num3);
}
static void findLargest(int num1,int num2, int num3){
if(num1>=num2 && num1>=num3){
System.out.println(num1+" is the greatest number");
}
else if(num2>=num1 && num2>=num3){
System.out.println(num2+" is the greatest number");
}
else{
System.out.println(num3+" is the greatest number");
}
1. Embed your method in a complete program that requests for three
variables all of the types int and displays the conditions explained in
the code above.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images