Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab, you need to create three simple methods that will count from 1 to 630 by 37s. One method will use a for

For this lab, you need to create three simple methods that will count from 1 to 630 by 37s. One method will use a for loop; one using a while loop, and one using a do loop. In each of these methods, label the output for the type of loop and print the values on a single line. In the application method, instantiate the class and call the three methods.

Here is a sample output:

Using a for loop: 1 38 75 112 149 186 223 260 297 334 371 408 445 482 519 556 593 630 Using a while loop: 1 38 75 112 149 186 223 260 297 334 371 408 445 482 519 556 593 630 Using a do loop: 1 38 75 112 149 186 223 260 297 334 371 408 445 482 519 556 593 630

That's all there's to it. Just use the loops to print out these values.

Note: There are actually two forms for the for loop in Java. For this lab, you must use the form that has two semicolons within the parentheses. This is the one presented in the notes this week. Later, we'll learn about the other for loop.

Check Level

For the check level, add punctuation. That is put commas between the values and a period at the end of the line.

Note: There should be no comma before the first value, nor after the last.

Using a for loop: 1, 38, 75, 112, 149, 186, 223, 260, 297, 334, 371, 408, 445, 482, 519, 556, 593, 630. Using a while loop: 1, 38, 75, 112, 149, 186, 223, 260, 297, 334, 371, 408, 445, 482, 519, 556, 593, 630. Using a do-while loop: 1, 38, 75, 112, 149, 186, 223, 260, 297, 334, 371, 408, 445, 482, 519, 556, 593, 630.

For check credit, do not use the if statement within your methods.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions