Answered You can hire a professional tutor to get the answer.

QUESTION

Please check my program is a Paycheck_SIM and isn't working for me #includeiostream #includecstring #includeiomanip using namespace std; string...

Please check my program is a Paycheck_SIM and isn't working for me

#include<iostream>

#include<cstring>

#include<iomanip>

using namespace std; 

string removePunct(string &);

string toHundred(const string *, const string *, int);

string toThousand(string, const string *, int);

string toTenThousand(string, const string *, int);

string numToWord(string);

string formatCheck(string, string &, string);

void displayCheck(string, const string, const string, const string);

int main()

{

string amount;

string payDate;

string recipient;

string centAmount;

string wordAmount;

cout<< "This program can display a simulated paycheck.n";

cout<< "Enter the pay date in (mm/dd/yy): ";

cin>>payDate;

cout << "Enter the payee's name: ";

getline(cin,recipient);

cout << "Enter the dollar amount of check(two decimals): $";

getline(cin,amount);

 while (stod(amount)<=0.00||stod(amount)>9999.99)

 {

 cout << "This program does not accept negative dollar amounts, "

 << "or amounts over $10000.n";

 cout << "Please enter a valid number again: $";

 getline(cin,amount);

 }

string numToWord(amount);

 {

 const string oToTwenty[]={ "","one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten", "eleven ", "twelve ", "thirteen ", "fourteen ",

 "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen " };

 const string tenMult[]={ "", "", "twenty ", "thirty ", "fourty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninenty "};

  int numStore=stoi(amount);

  string numWord;

  string words;

  if (amount.length()<3)

  {

    words=toHundred(oToTwenty, tenMult, numStore);

  }

  else if (amount.length()==3)

  {

    words=toThousand(amount, oToTwenty, numStore) + toHundred(oToTwenty, tenMult, numStore % 100);

  }

  else if (amount.length()==4)

  {

    if (numStore % 1000<100)

    {

      words=toTenThousand(amount, oToTwenty, numStore) + toHundred(oToTwenty, tenMult, numStore % 100);

    }

    else

    {

      words=toTenThousand(amount, oToTwenty, numStore) + toThousand(amount, oToTwenty, numStore) + toHundred(oToTwenty, tenMult, numStore % 100);

    }

  }

  return numWord.append(words);

 }

string toHundred(const string *oToTwenty, const string *tenMult, int numSize);

 {

  string numStore; numSize<20?numStore.append(oToTwenty[numSize]):numStore.append(tenMult[numSize / 10] + oToTwenty[numSize % 10]);

  return numStore;

 }

string toThousand(string amount, const string *oToTwenty, int numSize);

 {

  string numStore;

  if (numSize > 999)

  {

    numSize = stoi(amount.erase(2, 3));

    numStore.append(oToTwenty[numSize % 1000 % 10] + "hundred ");

  }

  else

  {

    numSize = stoi(amount.erase(1, 2));

    numStore.append(oToTwenty[numSize] + "hundred ");    

  }

  return numStore;

 }

string toTenThousand(string amount, const string *oToTwenty, int numSize);

 {

  string numStore;

  numSize = stoi(amount.erase(1, 3));

  return numStore.append(oToTwenty[numSize] + "thousand ");

 }

string removePunct(string &amount);

 {

  string centAmount;

  for (size_t index=0;index<amount.length();index++)

  {

    if (ispunct(amount.at(index)))

    {

      centAmount.append(amount, index + 1, 3);  

      amount.erase(index, 3);      

    }  

  }

  if (centAmount.empty())

  {

    centAmount.append("00");

  }

  else if (centAmount.length() == 1)

  {

    centAmount.append("0");

  }

  return centAmount;

 }

string formatCheck(string amount, string &wordAmount, string centAmount);

 {

  centAmount = removePunct(amount);

  wordAmount = numToWord(amount);

  wordAmount.append("dollar(s) and " + centAmount + " cents");

  wordAmount.at(0) = toupper(wordAmount.at(0));

  return wordAmount;

 }

void displayCheck(string amount, const string payDate, const string recipient, const string wordAmount);

 {

  cout << fixed << showpoint << setprecision(2);

  cout << "nt" << setw(68) << setfill('-') << "nn";

  cout << setfill(' ') << "n" << setw(64) << right 

     << "Date: " << payDate << "n"

     << "tPay to the order of: " << setw(28) << left << recipient

     << setw(2) << right << "$" << stod(amount) << "nnt"

     << wordAmount << "nnt";

 }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question