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
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
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
Math,
6 months ago
Economy,
6 months ago
Hindi,
1 year ago
Chemistry,
1 year ago
India Languages,
1 year ago