Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 2 A: Finding multiples We've learned that in programming, there is a special operator for getting the whole number remainder of division: The Modulo

Assignment 2A:
Finding multiples We've learned that in programming, there is a special operator for getting the
whole number remainder of division: The Modulo Operator! So,12%9 will give us a value of
3, since 9 goes evenly into 12 once with a remainder of 3.
There are many uses for this operator which we will learn throughout the semester. In this
assignment, we're going to use it to find the nearest multiple of a number based on user input.
For example, if we're looking for multiples of 6?, then the nearest multiple from 13? is 12?, and
the nearest multiple from 22? is 18?(rounded down).
Your task is to:
a) Ask the user to enter a whole number they want to find a multiple of
b) Read that value in
c) Ask the user to enter a second number
d) Read that value in
e) Use the Modulo Operator to find the nearest multiple of the first number from the
second number
f) Display the result to the user
The algorithm's output is as shown below, with user input in bold. Save your source code in a
file called Assignment2A (with a file extension of .cpp,.cs or .java)
Sample Output #1:
Enter a number you want to find a multiple of: 3
Enter a second number: 10
calculating...
The nearest multiple of 3 from 10 is 9!
Sample Output #2:
Enter a number you want to find a multiple of: 12
Enter a second number: 95
calculating...
The nearest multiple of 12 from 95 is 84!
Sample Output #3:
Enter a number you want to find a multiple of: 7
Enter a second number: 33
calculating...
The nearest multiple of 7 from 33 is 28!
image text in transcribed

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_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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

=+how many times?

Answered: 1 week ago