Friday, February 26, 2021

 

2.WAP IN JAVA TO INPUT TWO  NUMBERS AND DISPLAY THE LARGEST NUMBER AMONG THEM, IF BOTH THE NUMBERS ARE EQUAL , THEN DISPLAY A SUITABLE MESSAGE.

 

import java.util.*;

class Prog

{

 public static void main(String args[ ])

 {

   Scanner ob=new Scanner(System.in);

  int x,y;

System.out.print(“Enter the numbers”);

x=ob.nextInt();

y=ob.nextInt();

if(x==y)

System.out.println(“both the numbers are equal”);

if(x>y)

  System.out.println(x+”is largest”);

else

 System.out.println(y+”is largest”);

}

}

No comments:

Post a Comment

  3.WAP IN JAVA TO INPUT THREE NUMBERS AND COUNT HOW MANY OF THEM ARE EVEN .   import java.util.*; class Prog {   public static ...