Please help finish this function of this program. already have the pseudocode. c
ID: 3527373 • Letter: P
Question
Please help finish this function of this program. already have the pseudocode. const int SIZE = 81; // array size constants const int NUM_ONES = 10; const int NUM_TEENS = 20; const int NUM_TENS = 10; // onesPlc[] contains words for the numbers in the "ones" place char onesPlc[NUM_ONES][SIZE] = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" }; // teensW[] contains words for the teen numbers char teensW[NUM_TEENS][SIZE] = { "", "", "", "", "", "", "", "", "", "", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" }; // tensPlc[] contains the words for numbers in the tens place char tensPlc[NUM_TENS][SIZE] = { "", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" }; // inEnglish() prints an English word version of the value in num void inEnglish(double num); int main() { double value; // amount of the check char date[SIZE]; // check date char payee[SIZE]; // name of payee char again = 'y'; // loop control variable do { cout << " Enter the date: "; cin.getline(date, SIZE); // read date cout << " Enter name of the payee: "; cin.getline(payee, SIZE); // read payee cout << " Enter check amount: $"; cin >> value; // read check amount // --- insert code here to validate check amount --- cout << fixed << showpoint << setprecision(2); // float-pt format cout << "-------------------------------------------------------------------- "; cout << setw(50) << right; cout << "Date: " << date << " "; // display date cout << " Pay to the order of: " << payee << " "; cout << "$" << value << endl; inEnglish(value); // show English word version of amount cout << "-------------------------------------------------------------------- "; cout << " Another check? (Y/N): "; cin >> again; cin.get(); // get and ignore } while (toupper(again) == 'Y'); return 0; } void inEnglish(double num) { // declare int variables for thousands part, hundreds part, tens part, teens part // and cents // declare and initialize char array to null // // if num is exactly 10000.00 print words and return // extract thousands part (if it exists) from num and put words in char array // extract hundreds part (if it exists) from num // if tens part is greater than one // put words in char array // get ones part // if ones part is greater than zero put words in char array // else if tens part is equal to one // get teens part and put in char array // print the char array and any cents } // end inEnglish()Explanation / Answer
This IS the right answer
#include
#include
#include
using namespace std;
const int SIZE = 81; // array size constants
const int NUM_ONES = 10;
const int NUM_TEENS = 20;
const int NUM_TENS = 10;
// onesPlc[] contains words for the numbers in the "ones" place
char onesPlc[NUM_ONES][SIZE] = { "", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine" };
// teensW[] contains words for the teen numbers
char teensW[NUM_TEENS][SIZE] = { "", "", "", "", "", "", "", "", "",
"", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen",
"Sixteen", "Seventeen", "Eighteen", "Nineteen" };
// tensPlc[] contains the words for numbers in the tens place
char tensPlc[NUM_TENS][SIZE] = { "", "Ten", "Twenty", "Thirty",
"Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
// inEnglish() prints an English word version of the value in num
void inEnglish(double num);
int main()
{
double value; // amount of the check
char date[SIZE]; // check date
char payee[SIZE]; // name of payee
char again = 'y'; // loop control variable
do {
cout << " Enter the date: ";
cin.getline(date, SIZE); // read date
cout << " Enter name of the payee: ";
cin.getline(payee, SIZE); // read payee
cout << " Enter check amount: $";
cin >> value; // read check amount
// --- insert code here to validate check amount ---
cout << fixed << showpoint << setprecision(2); // float-pt format
cout << "-------------------------------------------------------------------- ";
cout << setw(50) << right;
cout << "Date: " << date << " "; // display date
cout << " Pay to the order of: " << payee << " ";
cout << "$" << value << endl;
inEnglish(value); // show English word version of amount
cout << "-------------------------------------------------------------------- ";
cout << " Another check? (Y/N): ";
cin >> again;
cin.get(); // get and ignore
} while (toupper(again) == 'Y');
return 0;
}
void inEnglish(double num)
{
// declare int variables for thousands part, hundreds part, tens part, teens part
// and cents
int thousands, hundreds, tens, ones, teens, cents;
// declare and initialize char array to null
char money[] = {""};
// if num is exactly 10000.00 print words and return
if(num == 10000.00)
{
cout << "
// extract thousands part (if it exists) from num and put words in char array
// extract hundreds part (if it exists) from num
// if tens part is greater than one
// put words in char array
// get ones part
// if ones part is greater than zero put words in char array
// else if tens part is equal to one
// get teens part and put in char array
// print the char array and any cents
} // end inEnglish()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.