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
Answers
Answered by
1
int a,n;
if a greater than 0
n = a*a;
else
n=a*a*a
if a greater than 0
n = a*a;
else
n=a*a*a
Answered by
0
Answer:
n=a*a*a is your answer
hope it helpfull
Similar questions
public class PositiveNegative
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int n=sc.nextInt();
int a,n;
if(a>0)
n=a*a;
else
n=(a*a*a);
}
}