Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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 using std::string;

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 #include #include "Numbers.h" using namespace std;

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 #include #include "Numbers.h" #include "Numbers2.cpp" using namespace std;

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; };

image text in transcribed

Above is the programming problem I'm struggling with.

image text in transcribed

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_string,class std::allocator > Numberstens"(? tens@Numbers@@OPAV?$basic_string@DU?$char_traits@D@std@@V? allocator@D@2@@std@@A) LNK2001 unresolved external symbol "private: static class std:basic_string,class std::allocator > Numberstens"(? tens@Numbers@@OPAV?$basic_string@DU?$char_traits@D@std@@V? allocator@D@2@@std@@A) LNK1120 1 unresolved externals LNK2005 "public:_thiscall Numbers:Numbers(int)" (??0Numbers@@OAE@H@Z) already 1 defined in Numbers.obi 3 LNK2005 "public: void_thiscall Numbers:print(void)" (?print@Numbers@@QAEXXZ) 1 already defined in Numbers.obj LNK2005 "public: class std:basic_string,class std:allocator > _thiscall Numbers:describeTens(int)"(? describeTens@Numbers@@OAE?AV?$basic_string@DU? char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Numbers.obj LNK2005 "private: static class std:basic_string,class std:allocator > Numbers:thousand" (?thousand@Numbers@@OV? basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in Numbers.obj LNK2005 "private: static class std:basic_string,class std:allocator > Numbers:hundred" (?hundred@Numbers@@0V? basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in Numbers.obj LNK2005 "private: static class std:basic_string,class std allocator >Numbers: zeroToTwenty" (? zeroToTwenty@Numbers@@OPAV?basic_string@DU?Schar_traits@D@std@@V? allocator@D@2@@std@@A) already defined in Numbers.obj LNK2005 "class std:basic_string,class std:allocator 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions