Assignment2A: Finding multiples We've learned that in programming, there is a special operator for getting the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Assignment2A: 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, 11 % 10 will give us a value of 1, since 10 goes evenly into 11 with a remainder of 1. 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! Assignment2A: 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, 11 % 10 will give us a value of 1, since 10 goes evenly into 11 with a remainder of 1. 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!
Expert Answer:
Answer rating: 100% (QA)
To accomplish this task you can use the following C code include int main Ste... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
what is resourced based view in public administration and why is it important?
-
Glenmount Inc. is trying to determine whether to use the FIFO or average cost method. The accounting records show the following selected inventory information: The company accountant has prepared the...
-
See the Web site for this book to read about the Whitmann Price Consulting case for this chapter. The following questions concern this Web case. Whitmann Price Consulting: Software Considerations...
-
Tyler Companys ASC 932-235 disclosures included the following information: REQUIRED: Using the information for Tyler Company in problems 13, 14, and 15 and in this problem: a. Compute the value of...
-
The graph in Figure represents various flows that can occur through a sewage treatment plant with the numbers on the arcs representing the maximum flow (in tons of sewage per hour) that can be...
-
27 Consider the following code: (5 Puan) Interface MyInterface ( } void myMethod(): abstract class MyAbstractClass I abstract void myAbstract Mothod (); class MyClass extends MyAbstractClass...
-
Mr. M has been employed as an engineer by A Ltd., a company incorporated in Hong Kong. During the year ended 31 March 2019, Mr. M had the following income and expenditure. A monthly salary of...
-
Budget committees would most likely include all of the following people EXCEPT Shareholder. OCEO. Marketing manager. Researdh and development manager.
-
What game was cancelled as a result of the 1967 San Jose State revolt? How much did it cost the school?
-
Ontario's Ministry of Transportation has advertised an A B contract for the repaving of a bridge on a busy 4-lane divided highway. The works must be completed with the bridge partially open, 2 lanes...
-
As a global generic strategy, Adaptation is most likely when?
-
What influence does media portrayal of undocumented immigrants exert on the shaping of perceptions regarding the Latino community?
-
What is the most common explanation for teenagers becoming pregnant in Canada?
-
What delay elements are involved in a disk read or write?
-
The first law of thermodynamics is sometimes whimsically stated as, You cant get something for nothing, and the second law as, You cant even break even. Explain how these statements could be...
-
Suppose a factory located next to a river discharges pollution that causes $2 million worth of environmental damage to the residents downstream. The factory could completely eliminate the pollution...
-
Consider a perfectly competitive market in which the market demand curve is given by Qd = 20 2Pd and the market supply curve is given by Qs = 2Ps. a) Find the equilibrium price and quantity in the...
-
You might think that when a production function has a diminishing marginal rate of technical substitution of labor for capital, it cannot have increasing marginal products of capital and labor. Show...
-
Cinnamon, Inc. recorded a total deferred tax asset in Year 3 of \($12\),301, off set by a \($12\),301 valuation allowance. Cinnamon most likely: A . fully utilized the deferred tax asset in Year 3. B...
-
Midland Brands issues three-year bonds dated January 1, 2015 with a face value of $5,000,000. Th e market interest rate on bonds of comparable risk and term is 3%. If the bonds pay 2.5% annually on...
-
A company issues $1,000,000 face value of 10-year bonds on January 1, 2015 when the market interest rate on bonds of comparable risk and terms is 5%. Th e bonds pay 6% interest annually on December...
Study smarter with the SolutionInn App