Design a class Numbers that can be used to translated whole dollars amounts in t
ID: 3534416 • Letter: D
Question
Design a class Numbers that can be used to translated whole dollars amounts in the range 0 through 9999 into an English description of the number. 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.
The class should have a single integer member variable
int number;
and a collection of static string members that specify how to translate key dollar amounts into the desired format. For example: you might use static strings such as:
string lessThan20[ ] =
{"zero", "one", ..., "eighteen", "nineteen" };
String hundred =
Explanation / Answer
class myNumber{
private:
int number;
string des;
public:
static const string lessThan20[];
static const string hundred;
static const string thousand;
Test(int n):number(n){}
void print();
}
const string myNumber::lessThan20[] = {"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
const string myNumber::hundred = "hundred";
const string myNumber::thousand = "thousand";
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.