Spring 2022
Question 2: [50 points]
1- Write a Java program as follows:
a- Write a method called isEven that takes an integer as a parameter. The method should return true if the integer is even or false otherwise.
b- Write a method called powOfTwo that takes an integer as a parameter, computes, and outputs its square (power of 2).
- In the main method, write a program that invokes the previously created methods to display the power of 2 of all the even numbers between 1 and a maximum number entered by the user. Your program should print a maximum of 5 results per line as shown in the below sample run.
Sample run:
Enter a number: 50
4 16 64 256 1024
1296 5184 20736 82944 331776
1327104 5308416 21233664 84934656 339738624
1358954496 5435817984 21743271936 86973087744 347892350976