1. Write a program to input three numbers and print the largest
of the three. Make use of logical operators.
Answers
Answered by
1
Answer:
public class Largest
{
public void main(int a,int b,int c)
{
if(a>b && a>c)
System.out.println("a is largest");
else if(b>a && b>c)
System.out.println("b is largest");
else
System.out.println("c is largest");
}
}
Answered by
1
Explanation:
import java.util.*;
class abc
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a,b,c;
System.out.println("Enter three numbers");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a>b && a>c)
System.out.println("The largest is="+a);
else if(b>a && b>c)
System.out.println("The largest is="+b);
else
System.out.println("The largest is="+c);
}
}
Similar questions