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
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...
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....
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...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the code to be written with these) I need Class river, Class CTRiver and Class Driver with comments so I can learn and better understand the code I also need a UML Diagram HELP Please! Class River describes river’s name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong()...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics relating to data supplied by the user. The program will ask the user to enter the number of items making up the data. It will then ask the user to enter data items one by one. It will store the data items in a double array. Then it will perform a number of statistical operations on the data. Finally, it will display a report...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT