ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

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

by | Nov 28, 2023 | engineering

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

 }

}

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!