Question: C++ program that converts a number in hexadecimal to binary or decimal. Your Hexadecimal class must include a member variable of type HexStack that stores

C++ program that converts a number in hexadecimal to binary or decimal.

Your Hexadecimal class must include a member variable of type HexStack that stores a hexadecimal number. HexStack must be a dynamic stack that implements the standard Stack operations: push, pop, and isEmpty, along with a default constructor and a destructor. No other operations are allowed in the HexStack class and the standard operations must be implemented as discussed in class, with the following addition: HexStack should only allow the values 0-9, A, B, C, D, E and F to be added to the stack.

The operations for your Hexadecimal class are listed below. They must be implemented by executing the 4 standard stack operations on the HexStack object that is a member variable for the Hexadecimal class.

Table 1

setValue

Stores a hexadecimal value, passed in as a string object.

showValue

Prints the currently stored value with the high-order bit first (on the left) and the low-order bit last (on the right). Non-destructive implementation.

getBin

Returns the binary equivalent of the currently stored value as a string. Non-destructive implementation.

getDec

Returns the decimal equivalent of the currently stored value as an int. Non-destructive implementation.

clearValue

Empties the current value

Default constructor

Creates a hexadecimal object with an empty value

2nd Constructor

Creates a hexadecimal object with an initial value, passed in as a string.

Write a main program to test your Hexadecimal class. It should include a menu that allows the user to: enter a Hexadecimal value (stored internally as a string), get the binary equivalent of the currently stored value, get the decimal equivalent of the currently stored value, or clear the current value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!