Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java !!!! While Loop: Count from N to M but quit if multiple of 7 is encountered. Write a program that increments an integer input,

Java !!!!

While Loop: Count from N to M but quit if multiple of 7 is encountered.

Write a program that increments an integer input, n, to m, but breaks away if the increment ever becomes a multiple of 7. Assume an integer named n is already defined for you and use that to increment. Additionally, assume an integer m is already defined for you, which will act as your limit to increment towards (note: you should be able to increment up to m, but not past it). Store the number of times that you loop through into an integer variable called count, which is also already defined, but not initialized. Examples: - If n = 8 and m = 20, the total number of loops will be 6 (since we encounter 14 along the way). - If n = -6 and m = 12, the total number of loops will be 14 (since we encounter 7 along the way). - If n = 9 and m = 10, the total number of loops will be 1 (since we get to m without encountering any multiples of 7). Note that 0 should not be a valid multiple of 7 at any point in your iterations.

Notice:

int count;

// TO-DO: Add your code here (use a do-while loop). // Increment n for each loop that is not a multiple of 7 all the way to m. // Increment count for each time you loop through.

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago

Question

What qualities do you see as necessary for your line of work?

Answered: 1 week ago