Question: Write C++ below this Design a class Numbers that can be used to store a number between the range 0 through 9999 a single integer

Write C++ below this

Design a class Numbers that can be used to store a number between the range 0 through 9999

a single integer member variable: private int number;

and several member functions:

void setNumber() {..} // a nonnegative integer and initialize the number.

int getNumber() {..} // return the number

and constructor that initialize the number to 0 (zero).

Create a subclass Words that convert the number into an English description of the number. (Inheritance)

For example, the number 713 would be translated into the string seven hundred thirteen, and 8203 would be translated into eight thousand two hundred three.

a member variable : private string words;

A collection of string members variables that specify how to translate key number into the desired format. For example, you might use static strings such as

string lessThan20[ ] = {"zero", "one", , "eighteen", "nineteen" };

string hundred = "hundred";

string thousand = "thousand";

and several member functions:

void ConvertNumber() {..} // convert the number into an English description

string PrintWords() {..} // return English description of the Numbers object

and constructor that initialize the words to nothing ().

Demonstrate the classes by writing a main program that asks the user to enter a number in the proper range and then prints out its English description. Only can create an object from the Words class

Write C++ below this Design a class Numbers that can be used

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!