Loops are foundational for computer programming. Almost every program uses at least one loop.
Do not use function calls instead of looping. Make sure the your programs have a while loop or a for loop.
Submit each of the following practice assignments at codePost.io.
To register for a free codePost account, please follow these instructions.
Watch this short video for a demonstration of submitting an assignment and reviewing the results:
Note, currently, feedback is not visible in Safari.
Write a Java program that requests the following three int values from the user:
Save your Java program in a file named NumericSeriesWhileLoops.java.
Example 1:
Please enter the starting number: 10 Please enter the ending number: 22 Please enter the step size: 3 The numbers in the series that starts with 10, goes to (but not including) 22 by steps of 3 are: 10 13 16 19(Notice that 22 is not included in the output)
Example 2:
Please enter the starting number: 10 Please enter the ending number: 0 Please enter the step size: -1 The numbers in the series that starts with 10, goes to (but not including) 0 by steps of -1 are: 10 9 8 7 6 5 4 3 2 1(Notice that the increment size is negative)
Example 3:
Please enter the starting number: 1000 Please enter the ending number: 10 Please enter the step size: 51 The numbers in the series that starts with 1000, goes to (but not including) 10 by steps of 51 are: Empty set(Notice that Empty set is required)
Hints:
Write a Java program that requests the following three int values from the user:
Save your Java program in a file named NumericSeriesForLoops.java.
Example 1:
Please enter the starting number: 10 Please enter the ending number: 22 Please enter the step size: 3 The numbers in the series that starts with 10, goes to (but not including) 22 by steps of 3 are: 10 13 16 19(Notice that 22 is not included in the output)
Example 2:
Please enter the starting number: 10 Please enter the ending number: 0 Please enter the step size: -1 The numbers in the series that starts with 10, goes to (but not including) 0 by steps of -1 are: 10 9 8 7 6 5 4 3 2 1(Notice that the increment size is negative)
Example 3:
Please enter the starting number: 1000 Please enter the ending number: 10 Please enter the step size: 51 The numbers in the series that starts with 1000, goes to (but not including) 10 by steps of 51 are: Empty set(Notice that Empty set is required)
Hints: