You have to find out the square, cube and fourth power of a given positive integer. The input will be a single line containing a single positive integer (n). The output should be three lines, first line prints the square of n, next line prints the cube of n and third line prints the fourth power of n.
Arithmetic operations
Calculating square, cube and fourth power of a number
Report a typo
Sample Input 1:
5Sample Output 1:
25
125
625Sample Input 2:
2Sample Output 2:
4
8
16Write a program in Java 17
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
// Create a Scanner object to read input
Scanner in = new Scanner(System.in);
// Read the next integer
int n = in.nextInt();
// Compute and print the square of n
// Compute and print the cube of n
// Compute and print the fourth power of n
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.