Write a program to accept a number. If the number is positive display its square.If the number is negative display its cube.USE SCANNER CLASS.
GIVE FULL JAVA PROGRAM
Answers
Answered by
0
Answer:
Explanation:
//first of all you need to import Scanner class given below:
import java.util.Scanner;
class First{
public static void main(String[] args) {
Scanner scn = new Scanner(System.in); //allocate memory using new keyword to scanner object
int num;
System.out.print("Enter any Number = ");
num=scn.nextInt(); // input dynamic value by user using scanner object
if(num >= 0){
System.out.print("Its Square");
}
else{
System.out.print("Its Cube");
}
}
}
thank you,
if you found this is helpful to you please add me in brainliest.
Similar questions
English,
8 months ago
Math,
8 months ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago
Art,
1 year ago
Social Sciences,
1 year ago