C++ - Reverse Digit
Problem: Certain mathematical problems involve manipulation of the digits within a decimal number. One such problem requires that the digits be reversed.
Your assignment: Write 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 a single instance variable of type 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.
? Your program must read an indefinite series of integers from the console (as integers, 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.
? 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 a method 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 order. For instance, if the input value is -0315863, the sorted value would be 133568. The sign of the input value should be discarded for this output
using namespace std;
cout << "Enter card type:";
cin >> cardType;...
This question was answered on: Sep 18, 2020
Buy this answer for only: $15
This attachment is locked
We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)
Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
About this QuestionSTATUS
Sep 18, 2020EXPERT
GET INSTANT HELP/h4>
We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.
You can also use these solutions:
- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
NEW ASSIGNMENT HELP?
Order New Solution. Quick Turnaround
Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.
WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.