Computer Science, asked by shallu21, 1 year ago

Write a program to input two numbers a ,b,display the square of a otherwise square of b . ( hint : use conditional operator) plz also give me the output

Answers

Answered by aditijaiswal810
5

Explanation:

public class Square

{

public void main(int a,int b)

{

if(a>b)

int s=a×a;

System.out.println("square="+s);

else

int s= b×b;

System.out.println("square="+s);

}

}

Answered by ansajpandey14
5

Answer:

import java.util.Scanner;

public class JavaExample

{

public static void main(String args[])

{

int a,b,s,q;

Scanner sc = new Scanner(System.in);

a = sc.nextInt();

b = sc.nextInt();

s= a*a;

q=b*b;

if (a>b)

System.out.print("Square= "+s);

else

System.out.print("Square=" +q );

}

}

Similar questions