Here are the original directions:
For this lab you will develop and test a Class called MathTasks with the following functionality. Include in your Lab Log sample runs on all provided test data.
1. a method called sumFor that has an integer parameter n and computes the sums of all the integers from 1 to n using a for construct. (hint: We already wrote the code in class – use your notes) Test on: 3,4,5,6,7
2. a method called sumWhile that does the same thing as sumFor, except that it is written using a while construct rather than a for construct. Test on: 3,4,5,6,7
3. a method called sumDoWhile that does the same thing as sumFor and sumWhile, except that it is written using a do_while construct rather than a for or while construct. Test on: 3,4,5,6,7
4. a method called sumIJ with two integer parameters i and j and computes the sums of all the integers from i to j using the most appropriate loop construct. Test on: (1,6),(3,4),(2,7)
5. a method called printPositiveEven that has an integer parameter n and prints all positive even numbers smaller or equal to n. Test on: 3,14,25, 32
6. a method called printAllMultiplesOfThree that has an integer parameter n and prints all positive numbers smaller or equal to n that are multiples of 3. Test on: 4,9,17,26,31
7. a method called printStars that has an integer parameter n and prints a line with n * characters. Test on: 3,4,5,6
ex: if the parameter n is 5 it prints *****
if the parameter n is 8 it prints ********
8. a method called printStarLines that has two integer parameters m and n and prints m lines. The first line has n * characters, the next one n+1, and so on. Test on: (2,5),(4,2),(5,5)
ex: if the parameter m is 4 and n is 6, then it prints:
******
*******
********
*********
9. a method called printStarLinesDecreasing that has two integer parameters m and n and prints 2*m-1 lines. The first line has n * characters, the next one n+1, and so on until the mth line has n+m-1, the (m+1)th line has n+m-2 and so on until the last one has n * characters. Test on: (2,5),(4,2),(5,5)
ex: if the parameter m is 3 and n is 5, then it prints:
*****
******
*******
******
*****
10. a method called isPowerOfTwo that has an integer parameter n and returns true if n is a power of 2, false otherwise. Test on: 3,4,8,12,32,33,100, 256,1024,1025
I need some help with the last two. Can anyone help me out? thanks!