Integers Assignment | Homework For You
February 17th, 2020
Write a C++ class to convert a string representing a positive integer or positive decimal value into the long int and double numeric types. If the string value represents a decimal value, the converted integer version will be truncated. If the string value represents an integer, the converted decimal value will have a decimal portion of zero.
Your code must use a character stack class in your conversion. You may use two stacks for the conversion if you wish. Your stack class must be based on the integer stack class in the example code below. Your “convert to numeric” class should have member functions for the following tasks:
• an overloaded constructor that accepts the string to convert
• a convert member function that accepts a string and returns a boolean success status
• a getintValue member function that returns the converted value as a long int
• a getDecValue member function that returns the converted value as a double
Create a driver program to demonstrate your class. The driver will prompt the user and accept a string representing a positive integer or decimal, then use your class to convert it. Finally, demonstrate the converted value is useable with any type specific operation, both as a long int and double. Get Finance homework help today