Patrick Star aspired to be a musician of note (ha!) specializing in Mayonnaise. Unfortunately, Patrick's music...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Patrick Star aspired to be a musician of note (ha!) specializing in Mayonnaise. Unfortunately, Patrick's music career didn't pan out. Now, Patrick has decided that he needs to make a name for himself has a math tutor with services offered through his startup. To demonstrate his abilities, Patrick has put together a very complex equation. When given a number, Patrick will calculate the difference between the number and its reverse, and subtract from that a random number at most as large as the original number. After confusing a lot of people, he gets you to design a program to do it for him instead. Write a C++ program that, given a number 'num' will calculate the required value. For example, if the number were 1234, you need to calculate || 1234-4321|-random%1234| Please make sure you conform to the following requirements: 1. Call this program numberflip.cpp 2. Write a function called reverseDiff that takes an integer as a parameter and returns the difference between the number and its reverse. Please note the "difference" is always positive. (20 points) 3. Write a function called calcVal that accepts a number as a parameter, calculates the required value for that number, and returns it. This function should call the reverseDiff function and the Random Number Generator (RNG) to get a random number. (10 points) 4. In main, first get a seed from the user to seed the RNG. (3 points) 5. Then, accept a series of numbers from the user. Stop if the number entered is 0. Use the calcVal function to find the required value for each of the numbers as they are entered, print them. (10 points) 6. Finally, calculate the average value and print it. (2 points) 7. Make sure you add comments to explain your logic. (5 points) 8. You are only allowed the iostream, cmath, and cstdlib libraries for this problem. Sample Run Please note that your output might be different due to the use of the RNG. Enter the seed for the RNG: 6746464 Enter a number: 501 The required value is 152 Enter the next number: 874 The required value is 542 Enter the next number: 1236 The required value is 1025 Enter the next number: 984 The required value is 769 Enter the next number: 25478 The required value is 19227 Enter the next number: 0 The average is 4343 Patrick Star aspired to be a musician of note (ha!) specializing in Mayonnaise. Unfortunately, Patrick's music career didn't pan out. Now, Patrick has decided that he needs to make a name for himself has a math tutor with services offered through his startup. To demonstrate his abilities, Patrick has put together a very complex equation. When given a number, Patrick will calculate the difference between the number and its reverse, and subtract from that a random number at most as large as the original number. After confusing a lot of people, he gets you to design a program to do it for him instead. Write a C++ program that, given a number 'num' will calculate the required value. For example, if the number were 1234, you need to calculate || 1234-4321|-random%1234| Please make sure you conform to the following requirements: 1. Call this program numberflip.cpp 2. Write a function called reverseDiff that takes an integer as a parameter and returns the difference between the number and its reverse. Please note the "difference" is always positive. (20 points) 3. Write a function called calcVal that accepts a number as a parameter, calculates the required value for that number, and returns it. This function should call the reverseDiff function and the Random Number Generator (RNG) to get a random number. (10 points) 4. In main, first get a seed from the user to seed the RNG. (3 points) 5. Then, accept a series of numbers from the user. Stop if the number entered is 0. Use the calcVal function to find the required value for each of the numbers as they are entered, print them. (10 points) 6. Finally, calculate the average value and print it. (2 points) 7. Make sure you add comments to explain your logic. (5 points) 8. You are only allowed the iostream, cmath, and cstdlib libraries for this problem. Sample Run Please note that your output might be different due to the use of the RNG. Enter the seed for the RNG: 6746464 Enter a number: 501 The required value is 152 Enter the next number: 874 The required value is 542 Enter the next number: 1236 The required value is 1025 Enter the next number: 984 The required value is 769 Enter the next number: 25478 The required value is 19227 Enter the next number: 0 The average is 4343
Expert Answer:
Related Book For
Applied Statistics For Public And Nonprofit Administration
ISBN: 9781285737232
9th Edition
Authors: Kenneth J. Meier, Jeffrey L. Brudney, John Bohte
Posted Date:
Students also viewed these programming questions
-
An instructor has decided that he needs a relational database to store grades in. He has defined the following three entities: STUDENT, COURSE, and ASSIGNMENT. What kind of relationship exists...
-
In what account is the difference between book value and the value implied by the purchase price recorded on the books of the investor? In what account is the "excess of implied over fair value"...
-
The difference between the second and third organisms. Why is the significance level different from that in Exercise 39 even though the observed difference of 10 mutations is the same in each case?...
-
Find the critical points of the function. Then use the Second Derivative Test to determine whether they are local minima, local maxima, or saddle points (or state that the test fails). f(x, y) = x -...
-
What is the role of angels as a source of new venture funding?
-
Compare and contrast different IPC mechanisms such as pipes, message queues, shared memory, and sockets. In what scenarios is each mechanism most appropriate, and what are the potential security...
-
Fluid flows past the two-dimensional bar shown in Fig. P9.2. The pressures on the ends of the bar are as shown, and the average shear stress on the top and bottom of the bar is \(\tau_{\text {avg....
-
Food Express is a well-established grocery chain. Computer Power is an up-and-coming computer software developer for business. Bridge Steel is an integrated steel producer, focusing on steel for...
-
What will be printed when the following code is executed? int sum=0; for (int x=0; x
-
Eta Corporation approaches Lily White, the CEO and sole shareholder of MuCo, regarding the acquisition of MuCo's cat toy division assets (worth $1.3 million). As selling the assets would create a...
-
A major subdivision project intended for housing is handled by a geodetic engineer. All survey aspect of the project has been accomplished by the said geodetic engineer and has been cleared by the...
-
demonstration of QuickSort on the [3,6,4,1,2,5,7,4] list. b) What happens when you're done? c) Describe an arrangement of the digits 1 to 8 that would make this algorithm very slow and explain why....
-
A rotor is mounted in bearings that are free to move in a single plane, as shown in the following figure. The rotor has total mass M and moment inertia JG (JG=ML) about its center of gravity. a. Draw...
-
nd Prove that for all n N, n+ 1 A="#4 2 1 < [] Where was this used in the proof of Lemma about the binary search? n 2 2 < n 2
-
Suppose matrix B has dimensions 5 \ times 3 and the matrix product AB has dimensions 1 \ times 9 What are the dimensions of matrix A ?
-
The most abundant radon isotope is radon-222, which is an alpha emitter with a half-life of 3.8 days. The air in a house basement in Canada is found to have a radon level of 500 Bq m. The World...
-
At date t, a trader takes a short position in a forward contract on gold. The date t forward price is $1,831.49 per ounce of gold and the contract size is 139 ounces. At the contract's expiration...
-
If your school has a subscription to the FASB Codification, go to aaahq.org/ ascLogin.cfm to log in and prepare responses to the following. (a) What is the stock dividend? (b) What is a stock split?...
-
The Office of Gerontology Policy (OGP) is considering a lawsuit against the Bureau of Investigations for age discrimination. OGP wants to base its suit on the following regression of civil service...
-
The Cancer Institute is evaluating an experimental drug for controlling lip cancer. Eighty lip cancer victims are randomly selected and given the drug for 1 year. Sixty other lip cancer victims are...
-
The data for the competencehierarchy example discussed earlier in the chapter are replicated in the accompanying table. Percentage the table and calculate gamma. Refer to the books website page for...
-
Explain how the financial manager might use industry norms in the design of the companys financing mix.
-
You have developed the following income statement for Sing-Tel Corporation. It represents the most recent years operations, which ended yesterday. Your supervisor in the controllers office has just...
-
Footwear, Inc. manufactures a complete line of mens and womens formal shoes for independent merchants. The average selling price of its finished product is \($85\) per pair. The variable cost for...
Study smarter with the SolutionInn App