Java lab 7 practicing loops
- In the WhileLoops class, write a method named eoCount that contains a while loop that reads in integers from System.in, and counts the even and odd numbers separately.
- In the WhileLoops class, write a method named mean that contains a while loop that reads in integers from System.in and calculates the mean of the numbers entered.
-
In the ForLoops class, create a method named forSum that calculates the sum 1+2+3+...+n where n is given as user input:
- Example output will look like below:
Number? 8 The sum is 36 -
In the ForLoops class, create a method named rangeSum that sums a range/interval of numbers, and prints the range. Your program should not care if the smaller or larger numbers are entered first:
- Example output will look like below:
Number? 8 Number? 3 The sum is: 33- The sum in the above example is the result of: 3 + 4 + 5 + 6 + 7 + 8
-
In the ForLoops class, implement a method named factorial that calculates the factorial of a number read in from System.in:
- e.g. 9 Factorial means: 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1;
- Example output will look like below:
Number: 9 Factorial: 362880
- In a class named ReWrites, rewrite the while loops in the sumRewrite method without the break condition and the boolean true in the parenthesis.
- In a class named ReWrites, rewrite the while loops in the avgRewrite method as a for loop instead of a while loop.
- Make sure to use the Git tab at the bottom of IntelliJ to create a Feature1 feature branch
- Commit and Push your running code back to your GitHub account
- Issue a Pull request back to my Java-Lab-007 repo
- Cut and Paste the Pull request URL into your Canvas assignment to turn it in.