#include <iostream> #include <string> #include <cctype> #include <iomanip> using namespace std; string convertToTwoDigitToWords(int, string); string numberToWords(unsigned long long int); const string EMPTY = ""; const string digits[] = { EMPTY, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " }; const string tens[] = { EMPTY, EMPTY, "Twenty-", "Thirty-", "Forty-", "Fifty-", "Sixty-", "Seventy-", "Eighty-", "Ninety-" }; string convertToTwoDigitToWords(int num, string suffix) { if(num == 0) return EMPTY; if(num > 19) { return tens[num / 10] + digits[num % 10] + suffix; } else return digits[num] + suffix; } string numberToWords(unsigned long long int num) { string words = ""; words = convertToTwoDigitToWords((num % 100), ""); if(num > 100 && num % 100) { words = words; } words = convertToTwoDigitToWords(((num / 100) % 10), "Hundred ") + words; words = convertToTwoDigitToWords(((num / 1000) % 100), "Thousand ") + words; words = convertToTwoDigitToWords(((num / 100000) % 100), "Lac, ") + words; words = convertToTwoDigitToWords(((num / 10000000) % 100), "Million, ") + words; words = convertToTwoDigitToWords(((num / 1000000000) % 100), "Billion, ") + words; return words; } int main() { string date, name; string amount; int dollar, cents; cout << "Enter date: "; cin >> date; cin.ignore(); cout << "Enter payee's name: "; getline(cin, name); cout << "Enter the amount: $"; cin >> amount; int posOfDot = amount.find("."); dollar = stoi(amount.substr(0, amount.find_first_of("."))); cents = stoi(amount.substr(posOfDot + 1)); string dollarInWords = numberToWords(dollar); string centsInWords = numberToWords(cents); double amt = stod(amount); cout << setprecision(2) << fixed; // printing the cheque cout << endl << "*****************************************************************************" << endl; cout << " Date: " << date << endl << endl << endl; cout << "Pay to the order of: " << name << " $" << amt << endl << endl; cout << dollarInWords << "dollars and " << centsInWords << "cents" << endl; cout << endl << "*****************************************************************************" << endl; return 0; }
************************************************************************ SCREENSHOT ***************************************************
write it in a c++ language Extra 11 - Pay to the Order Of.. (Due 5/29) A check writer.program. Write a program that...
this is for c++ please and thank you! 19. Check Writer Write a program that displays a simulated paycheck. The program should ask the user to enter the date, the payee's name, and the amount of the check (up to $10,000). It should then display a simulated check with the dollar amount spelled out, as shown here: Date: 11/24/2014 Pay to the Order of: John Phillips $1920.85 One thousand nine hundred twenty and 85 cents Be sure to format the...