Computer Science, asked by Wafeeqah9311, 1 month ago

Write a program to enter two unequal numbers. If the first number is greater than the second number, display the square of the smaller number and the cube of the greater number otherwise, vice-versa.

Answers

Answered by bakrihullisantosh
1

import java.io.*;

public class Number1

{

public static void main (String args[])throws IOException

{

InputStreamReader read = new InputStreamReader(System.in);

BufferedReader in = new BufferedReader(read);

int a,b,sq,cb;

System.out.println("Enter two numbers");

a=Integer.parseInt(in.readLine());

b=Integer.parseInt(in.readLine());

if(a!=b)

{

if(a<b)

{

sq=a*a;

cb=b*b*b;

}

else

{

sq=b*b;

cb=a*a*a;

}

System.out.println("The square of smaller number:"+sq);

System.out.println("The cube of greater number:"+cb);

}

else

System.out.println("Both the numbers are equal");

}

}

Similar questions