Write a program in java to input three numbers and display the greatest number (using or without using function.
Answers
Answered by
3
import java.util.Scanner;
public class Biggest_Number
{
public static void main(String[] args)
{
int x, y, z;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
x = s.nextInt();
System.out.print("Enter the second number:");
y = s.nextInt();
System.out.print("Enter the third number:");
z = s.nextInt();
if(x > y && x > z)
{
System.out.println("Largest number is:"+x);
}
else if(y > z)
{
System.out.println("Largest number is:"+y);
}
else
{
System.out.println("Largest number is:"+z);
}
}
}
Similar questions
Computer Science,
3 months ago
Math,
3 months ago
Science,
3 months ago
Computer Science,
7 months ago
Science,
11 months ago