Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class Numbers that can be used to translate whole dollar amounts in the

ID: 3641047 • Letter: D

Question

Design a class Numbers that can be used to translate whole dollar amounts in the range 0 through 9999 into a English description of the number
Also, demonstrate the class by writing a main program that loops asking the user to enter a number in the proper range and then prints its English description

Explanation / Answer

#include #include using namespace std; class Numbers{ static string decimals[20]; static string tens[8]; public: Numbers() {} void getEnglishString(int num){ if(num >=0 && num 0){ res += decimals[thousand]; res += " thousand, "; } if(hundreds > 0){ res += decimals[hundreds]; res += " hundred, "; } if(ten > 0 && ten < 2){ res+= decimals[ten*10 + digits] + " "; } else{ if(ten > 0){ res += tens[ten-2] + " "; } if(digits >0 ){ res+= decimals[digits]; } } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote