Computer Science, asked by ckcool, 6 months ago

Write a program to accept two numbers using Scanner class. If they are equal, display the message

“Both the numbers are equal”. If they are unequal, then find which one is greater. If the first number

is greater then, display square of the smaller number and cube of the greater number, otherwise, vice-

versa.a​

Answers

Answered by Anonymous
0

Answer:

script.js

var true

console.log

Explanation:

please Mark as brainliest and follow

Answered by anindyaadhikari13
2

Question:-

Write a program to accept two numbers using Scanner class. If they are equal, display the message that "both are equal". If they are unequal then find which one is greater. If the first number is greater than the second, then display the square of the smaller number and cube of the greater number and vice versa.

Code:-

Here is the code written in Java.

import java.util.*;

class X

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the first number: ");

int a=sc.nextInt();

System.out.print("Enter the second number: ");

int b=sc.nextInt();

if(a==b)

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

else if(a>b)

{

System.out.println("Cube of the greater number: "+(a*a*a);

System.out.println("Square of the smaller number: "+(b*b);

}

else

{

System.out.println("Cube of the smaller number: "+a*a*a);

System.out.println("Square of the bigger number: "+b*b);

}

}// end of main()

}// end of class.

Similar questions