Question
Assignment 5: Basic Loops and Functions Due Date 6/27/2018 The assignment is another exercise in using a particular language feature, loops. The intention is that
Assignment 5: Basic Loops and Functions Due Date 6/27/2018
The assignment is another exercise in using a particular language feature, loops. The intention is that you practice writing code with the small tasks. If you copy from other people you are only depriving yourself of an education. To learn, you have to think it through, yourself. Finding a solution online and copying it is easy, but leaves you facing the problem of learning what you were supposed to learn, in the context of a much harder problem the next time. To practice writing loops, create a class called Loops. The following methods should all be part of the Loops class. Turn in this assignment as a zip (or rar) folder that contains the entire project.
1. Write a loop that counts from 10 down to 1, printing the count value each time in the loop. The output should look like (notice the spacing): 10 9 8 7 6 5 4 3 2 1 Call this loop within main().
2. Write a loop that counts from 5 to 100 by fives, printing the count in each iteration. The output should look like: 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100 Notice the commas. Notice that there is no comma at the beginning or end. That means that you must do something special either at the beginning or at the end.
3. Write a scanner that takes an integer parameter The loop should count down, starting with the number that was passed using the scanner and ending with 0. For this you should use a for loop. The numbers should all appear on the same line. Advance to the next line at the end so that when the next printout is called, it prints on a new line.
So for example if the number passed in using scanner is 10 the output should be
10 9 8 7 6 5 4 3 2 1 0
4. Write a scanner that takes an integer parameter The loop should count up, starting with the number 1 and up to the number that was passed using the scanner. For this you should use a for loop. The numbers should all appear on the same line. Advance to the next line at the end so that when the next printout is called, it prints on a new line.
So for example if the number passed in using scanner is 7 the output should be
1 2 3 4 5 6 7
5. In the project class with the main function, do all these loops within the same main. Do not submit 4 different programs.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started