WAP in java to find which no. Is bigger
Answers
Answer:
using scanner
import java.util.*
public class Bigger
{
public static void main ( String args [])
{
scanner in =new scanner (system.in);
int a,b
System.out.print ( "Enter two numbers:")
a=in.nextInt();
b=in.nextInt();
if (a>b)
{
System.out.print (a+"is greater number");
}
else
{
system.out.println ( b+" is greater number");
}
}
} if you want to use function argument or input stream reader you can just edit the syntax
- Write a program in Java to find which number is bigger.
In this code, we will compute largest among two numbers.
import java.util.*;
class BiggerOne
{
public static void main(String s[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter first number: ");
int a=sc.nextInt();
System.out.print("Enter second number: ");
int b=sc.nextInt();
if(a==b)
System.out.println("Both are equal. ");
else if(a>b)
System.out.println("First number is greater than second. ");
else
System.out.println("Second number is greater than the first number.");
}
}