Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The for loop is very versatile. In this program, you will write a number of loops to achieve different results. Your Task: Use only statements


The for loop is very versatile. In this program, you will write a number of loops to achieve different results.

Your Task:

  1. Use only statements we have learned in class up to this point.
  2. New class called ForLoopVariety
  3. Loop that counts from 1 to 10 left to right with a space between.
  4. Loop that counts from 5 to 30 by 5's left to right with a space between.
  5. Loop that counts from 10 to 0 backwards left to right with a space between.
  6. Loop that prints a row of 10 asterisks resulting in: ********** The inside of your loop must use System.out.println("*"); and may not use System.out.println("**********");
  7. Create two nested for loops that prints 3 rows of 10 asterisks using System.out.println("*"); to create the asterisks with line numbers like: 1) ********** 2) ********** 3) ********** The inner loop must use System.out.println("*");; and may not use System.out.println("**********");
  8. For the next few steps, if you forgot how rand() works, go into your zyBook and use the search option at the top of the zyBook page to find rand() to review those details.
  9. Create a for loop that that prints 5 different random numbers between 0 and 99 from left to right with a space between.
  10. Create a for loop that prints 5 different random numbers between 7 and 11 from left to right with a space between.
  11. Create a for loop to print the numbers from 1 to 10 but skip the number 5 using continue.
  12. Create a for loop to print the numbers from 1 to 100 but stop the loop early if the number is divisible by 5 and 7 using break. Your for loop condition must be set to stop at 100 and must contain an if statement that includes a test involving % 5 and % 7.
  13. Take screen shot of output. Submit these screen shots showing your program running as shown in Required Output. The screen shots of output should be in a PDF file. Save your PDF file in your Documents folder as ForLoopVariety_output.pdf
  14. If you have any comments or concerns with your experience working on your program, please note them in the Comments area when you submit.

Required Program Name:

ForLoopVariety.java

Required Input:

  • There is no user input.

Required Output:

This is an example of running your program. It must include the program name and your name as well. The lines in bold show where random numbers will show up, so your results should be different.

Loops - Todd Darod 1 2 3 4 5 6 7 8 9 10 5 10 15 20 25 30 10 9 8 7 6 5 4 3 2 1 0 ********** 1) ********** 2) ********** 3) ********** 55 73 20 16 5 9 7 8 11 8 1 2 3 4 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

Checklist: What to Submit

  • ForLoopVariety.java
  • ForLoopVariety_output.pdf
image
 

Looping Ratings Pts Criteria 16 pts 1 to 10 5 to 30 by 5 10 to 0 backwards 10* 3 labeled rows of 10 * 5 rand 0 to 99 5 rand 7 to 11 16 pts 16 pts 16 pts 28 pts 30 pts 30 pts 24 pts 1 to 10 skip 5 24 pts 1 to 100 break on % 5 and % 7 Total Points: 200

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Absolutely heres the Java code for the ForLoopVari... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Programming questions

Question

What social problems are of particular interest to you?

Answered: 1 week ago