Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ hw 3 countdown due date: midnight, tuesday, feb. 26, 2019 problem: certain mathematical ... Your question has been answered Let us know if you

C++ hw 3 countdown due date: midnight, tuesday, feb. 26, 2019 problem: certain mathematical ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: HW 3 Countdown Due Date: Midnight, Tuesday, Feb. 26, 2019 Problem: Certain mathematical problem... HW 3 Countdown Due Date: Midnight, Tuesday, Feb. 26, 2019 Problem: Certain mathematical problems involve manipulation of the digits within a whole number. One such problem requires that the digits be re-arranged. Your assignment: Design, develop, and test an Object-Oriented C++ program that removes leading and trailing zeroes from an integer and then reverses the remaining digits. For example, the reversed value of 123450 is 54321, the reversed value of 005600 is 65; and the reversed value of -532 is -235. Develop a user-defined Number class to perform all the digit manipulations. Discussion: Extracting the digits from a decimal number involves repeated modulus and divide by 10 operations or conversion of the number to a printable string. Either method will work. How your Number class functions internally should be transparent to the user, e.g. there should be no cases in which the inner workings of the Number class produce unique results. Consider the following The Number class should have at least one instance variable of type integer or long integer and a method named reverse() that reverses the digits in the instance variable. Reversing the digits should not modify the value of the instance variable, but should create a new value and return that new value to the user as an integer or long integer. Your program must read an indefinite series of integers from the console (as numbers, no string input allowed). Use a single instance of the Number class to convert each input value to its reversed value. Stop when the user enters a value of zero. For each input value, display the input value and the value returned from the reverse() method. Coding Each class must be defined within its own set of .h and .cpp files. The program must accept any valid signed integer as input. Validate all inputs and do not proceed until valid values are entered. Format your source code according to the style guide presented in class. Bonus Extend the Number class to include one or more methods that will sort the digits from the input value after the leading and trailing zeroes are removed, returning a new integer with all its digits in ascending or descending order. For instance, if the input value is -0315863, the sorted ascending value would be 133568, and the sorted descending value would be 865331. The sign of the input value must be discarded by both these methods.

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions