Check writing program

Hello I am writing a check writing program. I have most of the program but I cant quite figure out the function to change the numbers to words. I have the pseudocode for the function though.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 << "\nEnter the date: ";
        cin.getline(date, SIZE);        // read date
        cout << "\nEnter name of the payee: ";
        cin.getline(payee, SIZE);       // read payee
        cout << "\nEnter check amount: $";
        cin >> value;                   // read check amount
          // --- insert code here to validate check amount ---

        cout << fixed << showpoint << setprecision(2);    // float-pt format
        cout << "--------------------------------------------------------------------\n";
        cout << setw(50) << right;
        cout << "Date: " << date << "\n\n";    // display date
        cout << "\tPay to the order of:  " << payee << "\t\t\t";
        cout << "$" << value << endl;
    
        inEnglish(value);    // show English word version of amount
        cout << "--------------------------------------------------------------------\n";
        cout << "\n 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() 
I don't understand how to extract the thousands ect part. Also I doont understand how to put the words in the char array.
Also, what is setprecision(2)
Setprecision(2) sets the number of digits after the decimal to 2.
I may change my major from computer science because I think you have to have a knack for it and I am unfortunately not a very good programmer because i have trouble understanding how it all works. I definitely respect people that can do it and wish I was better at it but I don't think I have what it takes
All you can do is practice. Programming in general is pretty simple if you understand all of the basic concepts. From the basic concepts, and with enough practice, writing code can become as comfortable with some people as speaking english, or a second language.

The hardest part, is getting to that point.
Topic archived. No new replies allowed.