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

12. Check Writer Write a program that displays a simulated paycheck. The program

ID: 3696574 • Letter: 1

Question

12. Check Writer

Write a program that displays a simulated paycheck. The program should ask the user to enter th date, the payee's name, and the amount of the check. It should then display a simulated check with the dollar amount spelled out. You may assume the amount is no greater than $10000. Be sure to format the numeric value of the check in fixed=point notation with two decimal places of precision. Be sure the decimal place always displays, even when the number is zero or has fractional part.l Use either C-strings or string class objects in this program.

In order to complete this assignment, create a class called TextVersionOfNumber

Be sure to not use a lot of "if" statements; use array processing.

(Here is the tester for the program)

// Chapter 12-- Assignment 14: Check Writer
// This program can convert a dollar and cents amount given in
// numerical form to a word description of the amount.
#include iostream
#include iomanip
#include string
#include string.h
using namespace std;

#include "TextVersionOfNumber.h"
// Assume a maximum amount of $10,000

int main()
{
    string date = "03/05/2016", payee = "Maya Tolappa";
    TextVersionOfNumber checkAmount;
    double testAmounts [] = {0, .01, .25, 12, 12.45, 19, 19.02,
                19.45, 20, 20.45,
                34, 56.78, 100, 109, 119.78,
                450, 678.90, 1000, 1009.45, 1056,
                1234, 1567.98,9999, 9999.99};
   
    for(int i=0; i < sizeof(testAmounts)/sizeof(double); i++)
    {
        double an_amount = testAmounts[i];
        checkAmount.setAmount(an_amount);
        cout << setprecision(2) << fixed;
        cout << setw(60) << right;
        cout << "Date: " << date << endl;
        cout << "Pay to the order of: " << payee << " ";
        cout << "$" << an_amount << endl;
        cout << checkAmount.getTextVersionOfNumber() << endl;
        cout << "--------------------------------------------------------------------- ";
    }
    return 0;
}

Explanation / Answer

#include iostream
#include iomanip
#include string
#include string.h
using namespace std;

#include "TextVersionOfNumber.h"
// Assume a maximum amount of $10,000

int main()
{
    string date = "03/05/2016", payee = "Maya Tolappa";
    TextVersionOfNumber checkAmount;
    double testAmounts [] = {0, .01, .25, 12, 12.45, 19, 19.02,
                19.45, 20, 20.45,
                34, 56.78, 100, 109, 119.78,
                450, 678.90, 1000, 1009.45, 1056,
                1234, 1567.98,9999, 9999.99};
   
    for(int i=0; i < sizeof(testAmounts)/sizeof(double); i++)
    {
        double an_amount = testAmounts[i];
        checkAmount.setAmount(an_amount);
        cout << setprecision(2) << fixed;
        cout << setw(60) << right;
        cout << "Date: " << date << endl;
        cout << "Pay to the order of: " << payee << " ";
        cout << "$" << an_amount << endl;
        cout << checkAmount.getTextVersionOfNumber() << endl;
        cout << "--------------------------------------------------------------------- ";
    }
    return 0;
}