Question
//Numbers.h #ifndef NUMBERS_H #define NUMBERS_H #include using std::string; class Numbers { private: int num; static string zeroToTwenty[20]; static string tens[10]; static string hundred; static string
//Numbers.h
#ifndef NUMBERS_H #define NUMBERS_H
#include
class Numbers { private: int num; static string zeroToTwenty[20]; static string tens[10]; static string hundred; static string thousand; public: Numbers(int); string describeTens(int); void print(); int getNumber() const {return num;} }; #endif
//Numbers2.cpp
#include
string Numbers::zeroToTwenty[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thriteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; string Numbers::hundred = "hundred"; string Numbers::thousand = "thousand"; string tens[] = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
Numbers::Numbers(int n) { num = n; }
string Numbers::describeTens(int n) { string tmpTens = ""; if (n = 20 && n % 10 == 0) { return tmpTens = tens[n / 10]; } else { return tmpTens = tens[n / 10] + " " + zeroToTwenty[n % 10]; } }
void Numbers::print() { string description = "";
if (getNumber() 999) { description.append(zeroToTwenty[getNumber() / 1000] + " " + thousand + ", ");
if (getNumber() % 1000
cout
//Number.cpp
#include
int main() { char again = ' '; // Temporary variable holding a user's choice int tempNum = 0; // Temporary variable to hold a number in an approriate range
cout
do { cout > tempNum;
while (tempNum 9999) { cout > tempNum; }
// Create a Numbers class object Numbers number(tempNum); number.print();
cout > again;
while (toupper(again) != 'Y' && toupper(again) != 'N') { cout > again; }
if (toupper(again) == 'N') { cout
} while (toupper(again) == 'Y');
cin.get(); cin.ignore(); return 0; };
Above is the programming problem I'm struggling with.
Above are most of the errors that appear when I try running my code. What's wrong with my code? Also, there are 3 files that are part of my final program.
1. Numbers Class Design a class Numbers that can be used to translate whole dollar 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 inte- ger member variable: int number; and a static array of string objects that specify how to translate key dollar amounts into the desired format. For example, you might use static strings such as string lessThan20 [20] = {"zero", string hundred"hundred" string thousand"thousand"; "one" , "eighteen", "nineteen"); , The class should have a constructor that accepts a nonnegative integer and uses it to initialize the Numbers object. It should have a member function print that prints the English description of the Numbers object. Demonstrate the class by writing a main program that asks the user to enter a number in the proper range and then prints out its English description. LNK2001 unresolved external symbol "private: static class std:basic_stringStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started