Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
633 B
1
Indexable
Never
import java.util.Scanner;

public class Power {
	public static void main(String[] args) {
		Scanner input = new Scanner (System.in);
		
		System.out.println("Please enter a number between 2 and 10:");
		
		int number = input.nextInt();
		
		while (number < 2 || number > 10) {
			System.out.println("Please enter a valid number:");
			number = input.nextInt();
		}
		
		int powerOfThree = (int) Math.pow(number, 3);
		int powerOfFive = (int) Math.pow(number, 5);
		
		System.out.println("The number inputted to the power of 3 is " + powerOfThree);
		System.out.println("The number inputted to the power of 5 is " + powerOfFive);
	}
}