Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Following the instructions to make a code that should include two while loops and a for loop. I have the code but there is something

Following the instructions to make a code that should include two while loops and a for loop. I have the code but there is something wrong with it because it is not outputting the correct multiples. I just need help fixing that mistake.

INSTRUCTIONS + SAMPLE RUNS

image text in transcribed

image text in transcribed

MY CODE + WRONG OUTPUT

image text in transcribed

This program asks for two inputs from the user: Max number, maxnum Divisor, divisor Then it displays all numbers that are multiples of divisor starting at 1 up to maxnum (inclusive) as shown in the sample runs below. You must use the remainder (%) operation for this task. Sample Runs (user input shown in green, with each run separated by a dashed line): Please enter the max number: 10 Please enter the divisor: 2 Multiples of 2 between 1 and 19 (inclusive) are: Please enter the max number: -2 Invalid input. Please enter a valid max number (> Invalid input. Please enter a valid max number (> Please enter the divisor: 3 Multiples of 3 between 1 and 19 (inclusive) are: ): -8 ): 10 Please enter the max number: 8 Please enter the divisor: -2 Invalid input. Please enter a valid divisor (> @): Invalid input. Please enter a valid divisor (> ): -5 Invalid input. Please enter a valid divisor (>0): 10 Multiples of 10 between 1 and 8 (inclusive) are: No number were found. Please enter the max number: 9 Invalid input. Please enter a valid max number (> 0): -10 Invalid input. Please enter a valid max number (>= @): 25 Please enter the divisor: Invalid input. Please enter a valid divisor (> 0): Invalid input. Please enter a valid divisor (> 0): -8 Invalid input. Please enter a valid divisor (> e): 4 Multiples of 4 between 1 and 25 (inclusive) are: @ 21 #99996- Quick Access RemainderFuncsample.java X 1 import java.util.Scanner; 2 public class Remainder Funcsample { 40 public static void main(String[] args) { // TODO Auto-generated method stub Scanner kbd = new Scanner(System.in); int count = 0; int rem = 0; int maxnum, divisor; System.out.print("Please enter the max number: "); maxnum = kbd.nextIntO; while (maxnum = 0): "); maxnum = kbd.nextIntO; System.out.print("Please enter the divisor: "); divisor = kbd.nextInt(); while (divisor 0): "); divisor = kbd.nextInt(); System.out.println("Multiples of " + divisor + " between 1 and " + maxnum + " (inclusive) are: "); for (int i = 1; i RemainderFuncsample [Java Application] /Library/Java/JavaVirtual Machines/jdk1.8.0_221.jdk/Contents/Home/bin/java (Feb 3, 2020, 3:12:31 PM) Please enter the max number: -9 Invalid input. Please enter a valid max number (>= 0): -10 Invalid input. Please enter a valid max number (>= 0): 25 Please enter the divisor: 0 Invalid input. Please enter a valid divisor (> ): 0 Invalid input. Please enter a valid divisor (> ): -8 Invalid input. Please enter a valid divisor (>): 4 Multiples of 4 between 1 and 25 (inclusive) are: 12345678910111213141516171819202122232425 Writable Smart Insert 27:5

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

Question

How is slaked lime powder prepared ?

Answered: 1 week ago

Question

Why does electric current flow through acid?

Answered: 1 week ago

Question

What is Taxonomy ?

Answered: 1 week ago

Question

1. In taxonomy which are the factors to be studied ?

Answered: 1 week ago