What do you do when it says..?

When it says "A-1-3-65) DISPLAY tab escape sequence, followed by RIGHT JUSTIFICATION, followed by

A-1-3-66) set width with value of the expression (length of the variable defined in A-1-3-58 above MINUS 3), followed by

A-1-3-67) literal for quantity-sold-for-product, followed by

A-1-3-68) value of product number entered, followed by two-character literal consisting of: colon and 1 space"
I am confused at what to do for the setwidth one and the value of product number one.

Also, do you see any other errors i might have?

I have this so far:
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*                                                                                   // A-1-1-01

Author:              Andrya Newman                                                       // A-1-1-02

Date Written:        December 11, 2011                                               // A-1-1-02

Course:              CSIS 123, Internet                                              // A-1-1-02

Program:             Task 07-02, Chapter 5                                           // A-1-1-02

Program Description: A mail-order house, Specialty Products, sells five products.    // A-1-1-02

                     This program prompts the user for a series of number pairs      // A-1-1-02

                     (product number and quantity sold for that product). It uses    // A-1-1-02

                     a sentinel-controlled "while" loop to determine when the        // A-1-1-02

                     program should stop accepting user input and, at the            // A-1-1-02

                     conclusion of the input phase, display the calculated results.  // A-1-1-02

                     The program validates the product number entered, ensuring that // A-1-1-02

                     it is an integer value from 1 through 5, inclusive. It issues   // A-1-1-02

                     an error message and rejects any user-entered product number    // A-1-1-02

                     that is outside the acceptable range. When a valid product      // A-1-1-02

                     number is entered it prompts for and accepts quantity sold      // A-1-1-02

                     for that product.                                               // A-1-1-02

Compiler Used:       Microsoft Visual C++ 2010 Express                               // A-1-1-02

SourceFile Name:     Task_07_02_Ch05.cpp                                             // A-1-1-02

*/                                                                                   // A-1-1-03

#include <iostream>                                                                  // A-1-1-04

#include <iomanip>                                                                   // A-1-1-05

#include <string>                                                                    // A-1-1-06

using namespace std;                                                                 // A-1-1-07

class MailOrder {                                                                    // A-1-1-08

    public:                                                                          // A-1-1-09

    void completeDailySalesReport() {                                                // A-1-1-10

        int quantitySoldByProduct[c_productCount] = {};                              // A-1-3-01

        const double unitPriceByProduct[] = {3.00, 4.50, 9.52, 5.00, 7.00};          // A-1-3-02

	cout << "\n\n Specialty Products: Daily Sales Report";                         // A-1-3-03 TODO

    cout << "\n\n Program Input:";                                                 // A-1-3-04 TODO

        getSalesByProduct(quantitySoldByProduct);                                    // A-1-3-05

    cout << "\n Program Output:";                                                // A-1-3-06 TODO

        displaySalesReport(quantitySoldByProduct, unitPriceByProduct);               // A-1-3-07

    } // function completeDailySalesReport                                           // A-1-1-11

    private:                                                                         // A-1-1-12

    const static int c_interColumnWidth = 4;                                         // A-1-1-13

    const static int c_productColumnWidth = 7;                                       // A-1-1-14

    const static int c_productCount = 5;                                             // A-1-1-15

    const static int c_quantityColumnWidth = 8;                                      // A-1-1-16

    const static int c_totalSalesColumnWidth = 11;                                   // A-1-1-17

    const static int c_unitPriceColumnWidth = 10;                                    // A-1-1-18

    void displayColumnHeadings() {                                                   // A-1-1-19

        cout << "\n\n\t" << right                                                    // A-1-3-08

            << setw(getProductColumnWidth()) << "Product"                            // A-1-3-09

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-10

            << setw(getQuantityColumnWidth()) << "Quantity"                          // A-1-3-11

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-12

            << setw(getUnitPriceColumnWidth()) << "Unit Price"                       // A-1-3-13

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-14

            << setw(getTotalSalesColumnWidth()) << "Total Sales"                     // A-1-3-15

            << "\n";                                                                 // A-1-3-16

    } // function displayColumnHeadings                                              // A-1-1-20
 void displayProductSales (int productNumber, int quantitySoldOfProduct,          // A-1-1-21

      double unitPriceOfProduct, double productSales) {                              // A-1-1-21

        cout << "\n\t" << right                                                      // A-1-3-17

            << setw(getProductColumnWidth()) << productNumber                        // A-1-3-18

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-19

            << setw(getQuantityColumnWidth()) << quantitySoldOfProduct               // A-1-3-20

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-21

            << fixed << showpoint << setprecision(2)                                 // A-1-3-22

            << setw(getUnitPriceColumnWidth()) << unitPriceOfProduct                 // A-1-3-23

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-24

            << setw(getTotalSalesColumnWidth()) << productSales;                     // A-1-3-25

    } // function displayProductSales                                                // A-1-1-22

void displaySalesReport(const int quantitySoldByProduct[],                       // A-1-1-23

      const double unitPriceByProduct[]) {                                           // A-1-1-23

        double extendedSalesThisProduct = 0.0;                                       // A-1-3-26

        double totalSalesAllProducts = 0.0;                                          // A-1-3-27

        displayColumnHeadings();                                                     // A-1-3-28

        for (int index = 0; index <= getProductCount() - 1; index++) {               // A-1-3-29

            extendedSalesThisProduct = quantitySoldByProduct[index]                  // A-1-3-30

                                     * unitPriceByProduct[index];                    // A-1-3-31

            totalSalesAllProducts += extendedSalesThisProduct;                       // A-1-3-32

            displayProductSales(index + 1, quantitySoldByProduct[index],             // A-1-3-33

                unitPriceByProduct[index], extendedSalesThisProduct);                // A-1-3-34 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
   } // for                                                                     // A-1-3-35

       displayTotalSales(totalSalesAllProducts);                                     // A-1-3-36 TODO

    } // function printSalesReport                                                   // A-1-1-24

    void displayTotalSales(double totalSales) {                                      // A-1-1-25

        const string c_totalSalesLabel = "Total Sales";                              // A-1-3-37

        const int c_totalSalesRightIndentWidth                                       // A-1-3-38

            = getProductColumnWidth()                                                // A-1-3-39

            + getQuantityColumnWidth()                                               // A-1-3-40

            + getUnitPriceColumnWidth()                                              // A-1-3-41

            + 3 * getInterColumnWidth()                                              // A-1-3-42

            - c_totalSalesLabel.length();                                            // A-1-3-43

        cout << "\n\n\t" << right                                                    // A-1-3-44 TODO

             << setw(getTotalSalesColumnWidth()) << "c_totalSalesLabel"                             // A-1-3-45 TODO
			  
             << setw(c_totalSalesRightIndentWidth) << " "                           // A-1-3-46 TODO

             << fixed << showpoint << setprecision(2)                                // A-1-3-47 TODO

             << setw(getTotalSalesColumnWidth()) << totalSales;                                  // A-1-3-48 TODO

    } // function displayTotalSales                                                  // A-1-1-26

    int getInterColumnWidth() {                                                      // A-1-1-27

        return c_interColumnWidth;                                                   // A-1-3-49

    } // function getInterColumnWidth                                                // A-1-1-28

    int getProductColumnWidth() {                                                    // A-1-1-29

        return c_productColumnWidth;                                                 // A-1-3-50

    } // function getProductColumnWidth                                              // A-1-1-30

    int getProductCount() {                                                          // A-1-1-31

        return c_productCount;                                                       // A-1-3-51

    } // function getProductCount                                                    // A-1-1-32

    int getQuantityColumnWidth() {                                                   // A-1-1-33

        return c_quantityColumnWidth;                                                // A-1-3-52

    } // function getQuantityColumnWidth                                             // A-1-1-34

    void getSalesByProduct(int quantitySoldByProduct[]) {                            // A-1-1-35

        const int c_lowestValidProductNumber = 1;                                    // A-1-3-53

        const int c_highestValidProductNumber = 5;                                   // A-1-3-54

        string enterKey;                                                             // A-1-3-55

        int productNumber;                                                           // A-1-3-56

        int quantitySoldOfProduct;                                                   // A-1-3-57

        string productPrompt = "Enter product number, or <ctrl>z <Enter> to stop: "; // A-1-3-58

        cout << "\n\n\t" << productPrompt;                                          // A-1-3-59 TODO

        while (!cin.eof()) {                                                         // A-1-3-60

            cin >> productNumber;                                                    // A-1-3-61 TODO

            if (productNumber >= c_lowestValidProductNumber                          // A-1-3-62

              && productNumber <= c_highestValidProductNumber                        // A-1-3-63

              && !cin.eof()) {                                                       // A-1-3-64

                  cout << "\t" << right                                             // A-1-3-65 TODO

                       << setw( productNumber - 3)                         // A-1-3-66 TODO

                       << "Quantity sold for product "                              // A-1-3-67 TODO

                       << productNumber << ": ";                             // A-1-3-68 TODO

                  cin >> quantitySoldOfProduct >> productNumber;              // A-1-3-69 TODO

                  quantitySoldByProduct[productNumber-1] += quantitySoldOfProduct;   // A-1-3-70

            } else {                                                                 // A-1-3-71

                if (!cin.eof()) {                                                    // A-1-3-72

                    cout << "\nInput Error: The Product Number you entered, \""      // A-1-3-73

                        << productNumber << ",\" is invalid;";                       // A-1-3-74

                    cout << "\nInput Error: Please enter a Product Number from \""   // A-1-3-75

                        << c_lowestValidProductNumber << "\" through \""             // A-1-3-76

                        << c_highestValidProductNumber << ",\" inclusive.\n";        // A-1-3-77

                } // if                                                              // A-1-3-78

            } // else                                                                // A-1-3-79

            if (!cin.eof())                                                          // A-1-3-80

                cout << "\n\t" << productPrompt;                                     // A-1-3-81

            // if                                                                    // A-1-3-82

        } // while                                                                   // A-1-3-83

        cin.clear();                                                                 // A-1-3-84

    } // function getSalesByProduct                                                  // A-1-1-36

    int getTotalSalesColumnWidth() {                                                 // A-1-1-37

        return c_totalSalesColumnWidth;                                              // A-1-3-85

    } // function getTotalSalesColumnWidth                                           // A-1-1-38

    int getUnitPriceColumnWidth() {                                                  // A-1-1-39

         return c_unitPriceColumnWidth;                                              // A-1-3-86

    } // function getUnitPriceColumnWidth                                            // A-1-1-40

}; // class MailOrder                                                                // A-1-1-41

int main() {                                                                         // A-1-5-01

    MailOrder myMailOrder;                                                           // A-1-5-02 TODO

    string enterKey;                                                                 // A-1-5-03

    cout << "\nTask 07-02, Ch05, Programmed by Andrya Newman";                           // A-1-5-04

    myMailOrder.completeDailySalesReport();                                     // A-1-5-05 TODO

    cout << ("\n\nEnd of Program: Press <Enter> to exit program.");                  // A-1-5-06

    getline(cin, enterKey);                                                          // A-1-5-07

} // function main                                                                   // A-1-5-08 
it is supposed to look like this:
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 Task 07-02, Ch05, Programmed by Ima Coder

 

Specialty Products: Daily Sales Report

 

Program Input:

 

        Enter product number, or <ctrl>z <Enter> to stop: 1

                             Quantity sold for product 1: 1

 

        Enter product number, or <ctrl>z <Enter> to stop: 2

                             Quantity sold for product 2: 5

 

        Enter product number, or <ctrl>z <Enter> to stop: 2

                             Quantity sold for product 2: 5

 

        Enter product number, or <ctrl>z <Enter> to stop: 3

                             Quantity sold for product 3: 100

 

        Enter product number, or <ctrl>z <Enter> to stop: 4

                             Quantity sold for product 4: 1000

 

        Enter product number, or <ctrl>z <Enter> to stop: 5

                             Quantity sold for product 5: 10000

 

        Enter product number, or <ctrl>z <Enter> to stop: 6

 

Input Error: The Product Number you entered, "6," is invalid;

Input Error: Please enter a Product Number from "1" through "5," inclusive.

 

        Enter product number, or <ctrl>z <Enter> to stop: ^Z

 

Program Output:

 

        Product    Quantity    Unit Price    Total Sales

 

              1           1          3.00           3.00

              2          10          4.50          45.00

              3         100          9.52         952.00

              4        1000          5.00        5000.00

              5       10000          7.00       70000.00

 

        Total Sales                             76000.00

 

End of Program: Press <Enter> to exit program.
 

What exactly is the problem though? I haven't read the previous 400 lines of your posts (nor do I intend to).
I have two items different from you and mine just worked.


<< setw( productNumber - 3) // A-1-3-66 TODO
I finally gave up with the productNumber and set it for << setw( 47 )

cin >> quantitySoldOfProduct >> productNumber; // A-1-3-69 TODO
this one I took off the productNumber because it would not let my solution work right.



thank you psych! i will try that! i really appreciate it!!!
ok i changed those but now where it says "Enter product number, or <ctrl>z <Enter> to stop: ^Z" It just keeps doing error input when i type in the ^Z. its like there is a loop that wont stop so i cant get the output to work.
I missed a difference. The following is my line. Personally Im just glad that you post like this because it give me a chance to figure out my mistakes. it is really hard to search the web for what the teacher wants with the language that he uses.

<< setw(getTotalSalesColumnWidth()) << c_totalSalesLabel // A-1-3-45 TODO
I know! I can spend forever on just one line trying to look it up in the book and online. I am happy you respond to these posts! it is a huge help!!
Ok and i changed that but it is still messed up. It completely freaks out once i type in the ^Z.
this is what i have now:
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*                                                                                   // A-1-1-01

Author:              Andrya Newman                                                       // A-1-1-02

Date Written:        December 11, 2011                                               // A-1-1-02

Course:              CSIS 123, Internet                                              // A-1-1-02

Program:             Task 07-02, Chapter 5                                           // A-1-1-02

Program Description: A mail-order house, Specialty Products, sells five products.    // A-1-1-02

                     This program prompts the user for a series of number pairs      // A-1-1-02

                     (product number and quantity sold for that product). It uses    // A-1-1-02

                     a sentinel-controlled "while" loop to determine when the        // A-1-1-02

                     program should stop accepting user input and, at the            // A-1-1-02

                     conclusion of the input phase, display the calculated results.  // A-1-1-02

                     The program validates the product number entered, ensuring that // A-1-1-02

                     it is an integer value from 1 through 5, inclusive. It issues   // A-1-1-02

                     an error message and rejects any user-entered product number    // A-1-1-02

                     that is outside the acceptable range. When a valid product      // A-1-1-02

                     number is entered it prompts for and accepts quantity sold      // A-1-1-02

                     for that product.                                               // A-1-1-02

Compiler Used:       Microsoft Visual C++ 2010 Express                               // A-1-1-02

SourceFile Name:     Task_07_02_Ch05.cpp                                             // A-1-1-02

*/                                                                                   // A-1-1-03

#include <iostream>                                                                  // A-1-1-04

#include <iomanip>                                                                   // A-1-1-05

#include <string>                                                                    // A-1-1-06

using namespace std;                                                                 // A-1-1-07

class MailOrder {                                                                    // A-1-1-08

    public:                                                                          // A-1-1-09

    void completeDailySalesReport() {                                                // A-1-1-10

        int quantitySoldByProduct[c_productCount] = {};                              // A-1-3-01

        const double unitPriceByProduct[] = {3.00, 4.50, 9.52, 5.00, 7.00};          // A-1-3-02

	cout << "\n\n Specialty Products: Daily Sales Report";                         // A-1-3-03 TODO

    cout << "\n\n Program Input:";                                                 // A-1-3-04 TODO

        getSalesByProduct(quantitySoldByProduct);                                    // A-1-3-05

    cout << "\n Program Output:";                                                // A-1-3-06 TODO

        displaySalesReport(quantitySoldByProduct, unitPriceByProduct);               // A-1-3-07

    } // function completeDailySalesReport                                           // A-1-1-11

    private:                                                                         // A-1-1-12

    const static int c_interColumnWidth = 4;                                         // A-1-1-13

    const static int c_productColumnWidth = 7;                                       // A-1-1-14

    const static int c_productCount = 5;                                             // A-1-1-15

    const static int c_quantityColumnWidth = 8;                                      // A-1-1-16

    const static int c_totalSalesColumnWidth = 11;                                   // A-1-1-17

    const static int c_unitPriceColumnWidth = 10;                                    // A-1-1-18

    void displayColumnHeadings() {                                                   // A-1-1-19

        cout << "\n\n\t" << right                                                    // A-1-3-08

            << setw(getProductColumnWidth()) << "Product"                            // A-1-3-09

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-10

            << setw(getQuantityColumnWidth()) << "Quantity"                          // A-1-3-11

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-12

            << setw(getUnitPriceColumnWidth()) << "Unit Price"                       // A-1-3-13

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-14

            << setw(getTotalSalesColumnWidth()) << "Total Sales"                     // A-1-3-15

            << "\n";                                                                 // A-1-3-16

    } // function displayColumnHeadings                                              // A-1-1-20

    void displayProductSales (int productNumber, int quantitySoldOfProduct,          // A-1-1-21

      double unitPriceOfProduct, double productSales) {                              // A-1-1-21

[code]
        cout << "\n\t" << right                                                      // A-1-3-17

            << setw(getProductColumnWidth()) << productNumber                        // A-1-3-18

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-19

            << setw(getQuantityColumnWidth()) << quantitySoldOfProduct               // A-1-3-20

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-21

            << fixed << showpoint << setprecision(2)                                 // A-1-3-22

            << setw(getUnitPriceColumnWidth()) << unitPriceOfProduct                 // A-1-3-23

            << setw(getInterColumnWidth()) << " "                                    // A-1-3-24

            << setw(getTotalSalesColumnWidth()) << productSales;                     // A-1-3-25

    } // function displayProductSales                                                // A-1-1-22
void displaySalesReport(const int quantitySoldByProduct[],                       // A-1-1-23

      const double unitPriceByProduct[]) {                                           // A-1-1-23

        double extendedSalesThisProduct = 0.0;                                       // A-1-3-26

        double totalSalesAllProducts = 0.0;                                          // A-1-3-27

        displayColumnHeadings();                                                     // A-1-3-28

        for (int index = 0; index <= getProductCount() - 1; index++) {               // A-1-3-29

            extendedSalesThisProduct = quantitySoldByProduct[index]                  // A-1-3-30

                                     * unitPriceByProduct[index];                    // A-1-3-31

            totalSalesAllProducts += extendedSalesThisProduct;                       // A-1-3-32

            displayProductSales(index + 1, quantitySoldByProduct[index],             // A-1-3-33

                unitPriceByProduct[index], extendedSalesThisProduct);                // A-1-3-34

        } // for                                                                     // A-1-3-35
Last edited on
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  displayTotalSales(totalSalesAllProducts);                                     // A-1-3-36 TODO

    } // function printSalesReport                                                   // A-1-1-24

    void displayTotalSales(double totalSales) {                                      // A-1-1-25

        const string c_totalSalesLabel = "Total Sales";                              // A-1-3-37

        const int c_totalSalesRightIndentWidth                                       // A-1-3-38

            = getProductColumnWidth()                                                // A-1-3-39

            + getQuantityColumnWidth()                                               // A-1-3-40

            + getUnitPriceColumnWidth()                                              // A-1-3-41

            + 3 * getInterColumnWidth()                                              // A-1-3-42

            - c_totalSalesLabel.length();                                            // A-1-3-43

        cout << "\n\n\t" << right                                                    // A-1-3-44 TODO

             << setw(getTotalSalesColumnWidth()) << c_totalSalesLabel               // A-1-3-45 TODO
			  
             << setw(c_totalSalesRightIndentWidth) << " "                           // A-1-3-46 TODO

             << fixed << showpoint << setprecision(2)                                // A-1-3-47 TODO

             << setw(getTotalSalesColumnWidth()) << totalSales;                                  // A-1-3-48 TODO

    } // function displayTotalSales                                                  // A-1-1-26

    int getInterColumnWidth() {                                                      // A-1-1-27

        return c_interColumnWidth;                                                   // A-1-3-49

    } // function getInterColumnWidth                                                // A-1-1-28

    int getProductColumnWidth() {                                                    // A-1-1-29

        return c_productColumnWidth;                                                 // A-1-3-50

    } // function getProductColumnWidth                                              // A-1-1-30

    int getProductCount() {                                                          // A-1-1-31

        return c_productCount;                                                       // A-1-3-51

    } // function getProductCount                                                    // A-1-1-32

    int getQuantityColumnWidth() {                                                   // A-1-1-33

        return c_quantityColumnWidth;                                                // A-1-3-52

    } // function getQuantityColumnWidth                                             // A-1-1-34

    void getSalesByProduct(int quantitySoldByProduct[]) {                            // A-1-1-35

        const int c_lowestValidProductNumber = 1;                                    // A-1-3-53

        const int c_highestValidProductNumber = 5;                                   // A-1-3-54

        string enterKey;                                                             // A-1-3-55

        int productNumber;                                                           // A-1-3-56

        int quantitySoldOfProduct;                                                   // A-1-3-57

        string productPrompt = "Enter product number, or <ctrl>z <Enter> to stop: "; // A-1-3-58

        cout << "\n\n\t" << productPrompt;                                          // A-1-3-59 TODO

        while (!cin.eof()) {                                                         // A-1-3-60

            cin >> productNumber;                                                    // A-1-3-61 TODO

            if (productNumber >= c_lowestValidProductNumber                          // A-1-3-62

              && productNumber <= c_highestValidProductNumber                        // A-1-3-63

              && !cin.eof()) {                                                       // A-1-3-64

                  cout << "\t" << right                                             // A-1-3-65 TODO

                       << setw( 47 )                                                 // A-1-3-66 TODO

                       << "Quantity sold for product "                              // A-1-3-67 TODO

                       << productNumber << ": ";                             // A-1-3-68 TODO

                  cin >> quantitySoldOfProduct;                              // A-1-3-69 TODO

                  quantitySoldByProduct[productNumber-1] += quantitySoldOfProduct;   // A-1-3-70

            } else {                                                                 // A-1-3-71

                if (!cin.eof()) {                                                    // A-1-3-72

                    cout << "\nInput Error: The Product Number you entered, \""      // A-1-3-73

                        << productNumber << ",\" is invalid;";                       // A-1-3-74

                    cout << "\nInput Error: Please enter a Product Number from \""   // A-1-3-75

                        << c_lowestValidProductNumber << "\" through \""             // A-1-3-76

                        << c_highestValidProductNumber << ",\" inclusive.\n";        // A-1-3-77

                } // if                                                              // A-1-3-78

            } // else                                                                // A-1-3-79

            if (!cin.eof())                                                          // A-1-3-80

                cout << "\n\t" << productPrompt;                                     // A-1-3-81

            // if                                                                    // A-1-3-82

        } // while                                                                   // A-1-3-83

        cin.clear();                                                                 // A-1-3-84

    } // function getSalesByProduct                                                  // A-1-1-36

    int getTotalSalesColumnWidth() {                                                 // A-1-1-37

        return c_totalSalesColumnWidth;                                              // A-1-3-85

    } // function getTotalSalesColumnWidth                                           // A-1-1-38

    int getUnitPriceColumnWidth() {                                                  // A-1-1-39

         return c_unitPriceColumnWidth;                                              // A-1-3-86

    } // function getUnitPriceColumnWidth                                            // A-1-1-40

}; // class MailOrder                                                                // A-1-1-41

int main() {                                                                         // A-1-5-01

    MailOrder myMailOrder;                                                           // A-1-5-02 TODO

    string enterKey;                                                                 // A-1-5-03

    cout << "\nTask 07-02, Ch05, Programmed by Andrya Newman";                           // A-1-5-04

    myMailOrder.completeDailySalesReport();                                     // A-1-5-05 TODO

    cout << ("\n\nEnd of Program: Press <Enter> to exit program.");                  // A-1-5-06

    getline(cin, enterKey);                                                          // A-1-5-07

} // function main                                                                   // A-1-5-08 
Last edited on
Topic archived. No new replies allowed.