Write a program to assign any number if number is even find square otherwise cube
Answers
Answered by
2
import java.util.*;
public class EO
{
public static void main (String args [])
{
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter A Value");
int num = sc.nextInt();
if ( num % 2 == 0 )
{
System.out.println("Even Number");
int sq = a*a;
System.out.println("Square of "+num+" = "+sq);
}
else if ( num % 2 == 1 )
{
System.out.println("Odd Number");
int cb = a*a*a;
System.out.println("Cube of "+num+" = "+cb);
}
else
{
System.out.println("Error");
}
sc.close();
}
}
Similar questions