The square of an integer refers to the result of multiplying the integer with itself once. While the cube of an integer refers to the result of multiplying the integer with itself twice. As long as you know that, you could easily solve this!
Instructions:
import java.util.Scanner;
import static java.lang.Math.pow;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter x: ");
int x = (int) pow(in.nextInt(),3);
System.out.print("Enter y: ");
int y = (int) pow(in.nextInt(),3);
System.out.print("Enter z: ");
int z = (int) pow(in.nextInt(),3);
int sum = x + y + z;
System.out.println(x);
System.out.println(y);
System.out.println(z);
if (sum >= 0) {
System.out.print("Positive");
} else {
System.out.print("Negative");
}
}
}
Comments
Leave a comment