Question

Problem: Certain mathematical problems involve manipulation of the digits within a whole number. One such problem...

Problem: Certain mathematical problems involve manipulation of the digits within a whole number. One such problem requires that the digits be re-arranged.In this project, we will reverse the order of the digits in a number.

Assignment: Design, develop, and test an Object-Oriented C++program that reads a whole number from the user, removes the sign and all leading and trailing zeroes from that number, and then performs the following operations on that number: 1) reverses the digits, 2) sorts the digits in descending order, and 3) sums the digits.For example, if the input value is -123450, the reversed value is 54321, the sorted value is 54321, and the sum of the digits is 15. Similarly, for an input value of 5600, the reversed value is 65, the sorted value is 65, and the sum of digits is 11.Develop a user-defined Digits class to perform all these digit manipulations.

Discussion: Extracting the digits from a whole number can be performed in at least two ways: 1) repeated modulus 10 and division by 10 operations, and 2)conversion of the number to a printable string and then examining the characters in the string. Either method will work, and both are acceptable. How your Digits class functions internally must be transparent to the user, e.g.there must be no cases in which the inner workings of the Digits class produce unique results dependent on its inner workings. Consider the following

•The Digits class must have at least one instance variable for the original value, one for the reversed value, one for the sorted value, and one for the sum of digits. The class must also include a setter method for the original value, and getters for the reversed value, sorted value, and sum of digits. None of the digit manipulations are allowed to modify the original value. All the getters must return their respective values to the user as whole numbers(not as strings).

•Your program must allow the user to enter a whole number(as a number, not a string)from the console and see its reversed value, sorted value, and the sum of its digits, and then to repeat this process until the user enters a zero.Use a single instance of the Digits class to manipulate all input values.

•For each input value, display the input value, its reversed value, its sorted value, and the sum of its digits.Coding

•Each user-defined class must be defined within its own set of .h (,hpp in Xcode) and .cpp files.

•The program must accept any valid signed whole number as input.Do not accept any value with a decimal fraction or other extraneous characters, including dollar signs.

•Validate all inputs and do not proceed until a valid value has been entered.

*** Make the code as simple as possible. Make sure to incude every requirements.

**There should be three files. The first first file is Digit.cpp, Digit.h, main.cpp

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Below is the assignment, I have completed and tested every step except for the last one....
Below is the assignment, I have completed and tested every step except for the last one. "Print aLine with the first 'c' 'C' 'd' or 'D' removed." any help would be appreciated ASSIGNMENT Write a program using Scanner and its nextLine method. The following is an example of how to use nextLine Scanner kybd = new Scanner(System.in); System.out.println("Enter a line of text"); String aLine = kybd.nextLine(); If the user's input is shorter than 7 characters, print the message "The input...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
In C++, create an input validation where the user enters a signed whole number and repeats...
In C++, create an input validation where the user enters a signed whole number and repeats this process until the user enters a zero. Do not accept any value with a decimal fraction or other extraneous characters, including dollar signs. The number's sign must be preserved. Some of the steps has been done for you. Fill out the program in C++. See below for the expected console output. Program: #include <iostream> using namespace std; int main(){    signed int input;...
Provide a complete solution to the following problem using the C++ language in a SINGLE file...
Provide a complete solution to the following problem using the C++ language in a SINGLE file with a .cpp file extension. READ THE ENTIRE QUESTION (AND THE EXAMPLE) CAREFULLY BEFORE DEVELOPING YOUR SOLUTION! Design the code for a class called Pi, which will be used to encapsulate the value of pi stored as a string. (example ONLY) "3.141592654" | |_ _ _ _| whole number portion_| |_ _ _ _ _fractional portion (9 digits) The Pi class has the following...
Problem: Our Armstrong number Please write code for C language So far we have worked on...
Problem: Our Armstrong number Please write code for C language So far we have worked on obtaining individual digits from 4 digits or 5 digit numbers. Then added them to find the sum of digits in various examples and assignments. However, the process of extracting individual digits is actually can be solved using a loop as you were doing a repetitive task by using mod operation and division operation. Now, we know how loops work and we can remove the...
Base Conversion One algorithm for converting a base 10 number to another base b involves repeatedly...
Base Conversion One algorithm for converting a base 10 number to another base b involves repeatedly dividing by b. Each time a division is performed the remainder and quotient are saved. At each step, the dividend is the quotient from the preceding step; the divisor is always b. The algorithm stops when the quotient is 0. The number in the new base is the sequence of remainders in reverse order (the last one computed goes first; the first one goes...
How to write a C++ program. Additive persistence is a property of the sum of the...
How to write a C++ program. Additive persistence is a property of the sum of the digits of an integer. The sum of the digits is found, and then the summation of digits is performed creating a new sum. This process repeats until a single integer digit is reached. Consider the following example: 1. The beginning integer is 1234 2. Sum its digits is 1+2+3+4 = 10 3. The integer is now 10 4. The sum of its digits is...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....
language: JAVA the Problem Below are a series of problems you need to solve using recursive...
language: JAVA the Problem Below are a series of problems you need to solve using recursive methods. You will write a program that will read commands from an input file, with each command referring to one of the recursive problems to be executed. Each command will be followed (on the same line of input) by the respective parameters required for that problem. (15 points for main method) DescArrayCheck   Write a recursive method that checks whether an array of integers -...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with a Program class and write the following two methods (headers provided) as described below: - A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number...