Compiling errors.

Hi, I'm working on a little project and I have some compiling errors that I can't fix.
This is my code:
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double SaleRecord(unsigned&, double&, unsigned&, double&, char&);
float calculateItemCost(char discountType, double itemPrice, double totalPrice, int quantity);
void calcTotalPrice(double totalPrice, unsigned Num, bool aborted);



int main()
{
unsigned itemID, quantity, records, totalQuantity;
char discountType;
double itemPrice, discount, transactionNumber, allPrices;

int totalRec;

SaleRecord(itemID&, itemPrice, discountType&, quantity, &transactionNumber); 
calculateItemCost(itemPrice, totalPrice, discountType, quantity); 
displayTotalPrice(totalPrice);


system("pause");
return 0;
}

void finalPrice(double finalPrice)
{
cout << "The final price with all of the items is " <<totalPrice;
return;
}


double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity){
float discount;
switch (discountType){

case 'N': discount=1;
break;

case 'n': discount=1;
break;

case 'B': discount=0.9;
break;

case 'b': discount=0.9;
break;

case 'D': discount=0.8;
break;

case 'd': discount = 0.8;
break;

case 'T': discount=0.7;
break;

case 't': discount=0.7;
break;

default: discount=1;
}
totalPrice=itemPrice*discount*quantity;

return totalPrice;
}

double SaleRecord(unsigned & quantity, float & itemPrice, unsigned & itemID, double & transactionNumber, char & discountType)
{
int anotherTransaction = 0;
cout << "Enter the 6 digit item ID starting with a number greater than 1:";
cin >> itemID;
if (itemID <=99999 || itemID >999999)
{
cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
system("pause");
exit(0);
}

cout << "Enter the price of the item:";
cin >> itemPrice;

if (itemPrice<0)
{
cout << "You didn't enter a valid price. Try again.";
system("pause");
exit(0);
}

cout << "Enter the discount type. The valid discount types are:\n\
\aN: No discount\n\
\aB: Basic discount (10%)\n\
\aD: Double discount (20%)\n\
\aT: Triple discount (30%)";
cin >> discountType;

if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
{
cout << "You didn't enter a valid discount type. Try again.";
system("pause");
exit(0);
}

cout << "Enter the quanity of item sold.";
cin >> quantity;
if (quantity<0)
{
cout << "You didn't enter a valid quantity sold. Try again.";
system("pause");
exit(0);
}
string multipleSales;
cout << "Would you like to perform another transaction? 'yes' or 'no'";
cin >> multipleSales;
transactionNumber++;


while( multipleSales == yes)
{
cout << "Enter the 6 digit item ID starting with a number greater than 1:";
cin >> itemID;

if (itemID <=99999 || itemID >999999)
{
cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
system("pause");
exit(0);
}

cout << "Enter the price of the item:";
cin >> itemPrice;

if (itemPrice<0.1f || itemPrice > 9999999)
{
cout << "You didn't enter a valid price. Try again.";
system("pause");
exit(0);
}

cout << "Enter the discount type. The valid discount types are:\n\
\aN: No discount\n\
\aB: Basic discount (10%)\n\
\aD: Double discount (20%)\n\
\aT: Triple discount (30%)";
cin >> discountType;

if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
{
cout << "You didn't enter a valid discount type. Try again.";
system("pause");
exit(0);
}

cout << "Enter the quanity of item sold.";
cin >> quantity;

if (quantity<0)
{
cout << "Invalid Entry. Please enter the correct Quantity";
system("pause");
exit(0);
}

cout << "Would you like to perform another transaction? 'yes' or 'no'";
cin >> anotherTransaction;
transactionNumber++;
}

return (itemID, quantity, discountType, itemPrice, transactionNumber);

}


Errors are:
13 expected `,' or `...' before '&' token
In function `int main()':
25 expected primary-expression before ',' token
25 expected primary-expression before ',' token
26 `totalPrice' undeclared (first use this function) < it's declared?
(Each undeclared identifier is reported only once for each function it appears in.)
27 `displayTotalPrice' undeclared (first use this function) < also declared
In function `void finalPrice(double)':

36 In function `double SaleRecord(unsigned int&, float&, unsigned int&, double&, char&)': `totalPrice' undeclared (first use this function)
126 `yes' undeclared (first use this function)

Thanks!
closed account (o3hC5Di1)
Hi there,

Here's some things that should at least reduce the amount of errors:

1
2
3
//line 13
unsigned int itemID, quantity, records, totalQuantity; 
//"unsigned" itsself is not a valid variable type i think 


1
2
3
//line 16
double itemPrice, discount, transactionNumber, allPrices, totalPrice;
//totalPrice needs to be declared before it can be used. 


Copy your main function underneath all your other functions as a quick fix too, or declare your functions before the main() function as for instance:

1
2
double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity);
//note the semicolon after the declaration 


Hope that helps.

All the best,
NwN
Last edited on
That helped a lot and I found where I went wrong in a few other places, thank you!
I'm down to one error now, I think this is a parsing error but don't know where I've gone wrong.
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double saleRecord(unsigned int&, double&, unsigned int&, double&, char&, int multipleSales);
double calculateItemCost(char discountType, double itemPrice, double totalPrice, int quantity);
void calcTotalPrice(double totalPrice, unsigned Num, bool aborted);
double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity);
double displayTotalPrice(double totalPrice);




int main()
{
    unsigned int itemID, quantity, records, totalQuantity;
    char discountType;
    double itemPrice, discount, transactionNumber, allPrices, totalPrice;

    int totalRec;

    saleRecord(itemID&, itemPrice, discountType, quantity, &transactionNumber); 
    calculateItemCost(discountType, itemPrice, totalPrice, quantity); 
    displayTotalPrice(totalPrice);


    system("pause");
    return 0;
}

    void finalPrice(double finalPrice)
{
    cout << "The final price with all of the items is " <<finalPrice;
    return;
}

double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity){
float discount;
switch (discountType){

              case 'N': discount=1;
              break;

              case 'n': discount=1;
              break;

              case 'B': discount=0.9;
              break;

              case 'b': discount=0.9;
              break;

              case 'D': discount=0.8;
              break;

              case 'd': discount = 0.8;
              break;

              case 'T': discount=0.7;
              break;

              case 't': discount=0.7;
              break;
       
              default: discount=1;
}
       totalPrice=itemPrice*discount*quantity;

       return totalPrice;
}

double saleRecord(unsigned & quantity, double & itemPrice, unsigned & itemID, double & transactionNumber, char & discountType)
{
       int multipleSales = 0;
       cout << "Enter the 6 digit item ID starting with a number greater than 1:";
       cin >> itemID;
       if (itemID <=99999 || itemID >999999)
          {

                  cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
                  system("pause");
                  exit(0);
                  }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0)
           {
           cout << "You didn't enter a valid price. Try again.";
           system("pause");
           exit(0);
           }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
             cout << "You didn't enter a valid discount type. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;
        if (quantity<0)
        {
             cout << "You didn't enter a valid quantity sold. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Would you like to perform another transaction? '1' for yes or '0' for no";
        cin >> multipleSales;
        transactionNumber++;


        while(multipleSales==1)
        {
        cout << "Enter the 6 digit item ID starting with a number greater than 1:";
        cin >> itemID;

        if (itemID <=99999 || itemID >999999)
        {
              cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0.1 || itemPrice > 9999999)
        {
              cout << "You didn't enter a valid price. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
              cout << "You didn't enter a valid discount type. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;

        if (quantity<0)
        {
              cout << "Invalid Entry. Please enter the correct Quantity";
              system("pause");
              exit(0);
        }

        cout << "Would you like to perform another transaction? 'yes' or 'no'";
        cin >> multipleSales;
        transactionNumber++;
        }

return (itemID, quantity, discountType, itemPrice, transactionNumber);

}

Error:
In function `int main()':
28 expected primary-expression before ',' token
Last edited on
Note that I have removed some lines just to make my answer shorter.
These are compilation errors- they will not let the code compile.
(There may be other operational/runtime errors - but we have to get the thing to compile first)

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
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double SaleRecord(unsigned&, double&, unsigned&, double&, char&);
float calculateItemCost(char discountType, double itemPrice, double totalPrice, int quantity);
void calcTotalPrice(double totalPrice, unsigned Num, bool aborted);



int main()
{
    unsigned itemID, quantity, records, totalQuantity;
    char discountType;
    double itemPrice, discount, transactionNumber, allPrices;

    int totalRec;

    //***ERROR - Incorrect way to call the saleRecord function
    SaleRecord(itemID&, itemPrice, discountType&, quantity, &transactionNumber);
    //***ERROR - what is this totalPrice variable??????????????? 
    calculateItemCost(itemPrice, totalPrice, discountType, quantity);
    
    //** ERROR - TWO errors on nect line:
    // 1. What is this displayTotalPrice function - I see no function prototype for it??
    //2. Where has this totalPrice variable suddenly appeared from??  again???????????
    displayTotalPrice(totalPrice); 


    system("pause");
    return 0;
}

void finalPrice(double finalPrice)
{
    cout << "The final price with all of the items is " <<totalPrice; //***ERROR - What is totalPrice????
    return;
}


double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity)
{
    //removed body to save space
}

double SaleRecord(unsigned & quantity, float & itemPrice, unsigned & itemID, double & transactionNumber, char & discountType)
{
    //Removed a lot of line to save  spce.

    while( multipleSales == yes) //******* ERROR - What is yes???? 
    {
        //removed some stuff to save space 
  
    }

    return (itemID, quantity, discountType, itemPrice, transactionNumber); //*** ERROR -  what are you trying to return her??
}
closed account (o3hC5Di1)
Hi,

regarding that last error:

1
2
//line 23
saleRecord(itemID&, itemPrice, discountType, quantity, &transactionNumber); 


The Ampersand (&) should be after the variable identifier, i.e. transactionNumber&

Hope that works.

All the best,
NwN
Thanks a lot guestgulkan, I'm now down to just one error - could you help me with this last one?
It's just about 5 AM here in Australia and I've been killing myself all night over this haha. I'm so close!
closed account (o3hC5Di1)
I just did :)

-N
Thanks NwN, I tried that but the error still remains and another appears:
28 expected primary-expression before ')' token
The thing is - now that you have made corrections, the line numbers in your new code probably don't match your original post.
So a code post update would be nice.
Here's the current code:
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*  
=
=    
*/

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double saleRecord(unsigned int&, double&, unsigned int&, double&, char&, int multipleSales);
double calculateItemCost(char discountType, double itemPrice, double finalPrice, int quantity);
void calcTotalPrice(double totalPrice, unsigned Num, bool aborted);
double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity);
double displayTotalPrice(double totalPrice);




int main()
{
    unsigned int itemID, quantity, records, totalQuantity;
    char discountType;
    double itemPrice, discount, transactionNumber, allPrices, totalPrice;

    int totalRec;

    saleRecord(itemID&, itemPrice, discountType, quantity, transactionNumber&); 
    calculateItemCost(discountType, itemPrice, totalPrice, quantity); 
    displayTotalPrice(totalPrice);


    system("pause");
    return 0;
}

    void finalPrice(double finalPrice)
{
    cout << "The final price with all of the items is " <<finalPrice;
    return;
}

double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity){
float discount;
switch (discountType){

              case 'N': discount=1;
              break;

              case 'n': discount=1;
              break;

              case 'B': discount=0.9;
              break;

              case 'b': discount=0.9;
              break;

              case 'D': discount=0.8;
              break;

              case 'd': discount = 0.8;
              break;

              case 'T': discount=0.7;
              break;

              case 't': discount=0.7;
              break;
       
              default: discount=1;
}
       totalPrice=itemPrice*discount*quantity;

       return totalPrice;
}

double saleRecord(unsigned & quantity, double & itemPrice, unsigned & itemID, double & transactionNumber, char & discountType)
{
       int multipleSales = 0;
       cout << "Enter the 6 digit item ID starting with a number greater than 1:";
       cin >> itemID;
       if (itemID <=99999 || itemID >999999)
          {

                  cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
                  system("pause");
                  exit(0);
                  }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0)
           {
           cout << "You didn't enter a valid price. Try again.";
           system("pause");
           exit(0);
           }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
             cout << "You didn't enter a valid discount type. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;
        if (quantity<0)
        {
             cout << "You didn't enter a valid quantity sold. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Would you like to perform another transaction? '1' for yes or '0' for no";
        cin >> multipleSales;
        transactionNumber++;


        while(multipleSales==1)
        {
        cout << "Enter the 6 digit item ID starting with a number greater than 1:";
        cin >> itemID;

        if (itemID <=99999 || itemID >999999)
        {
              cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0.1 || itemPrice > 9999999)
        {
              cout << "You didn't enter a valid price. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
              cout << "You didn't enter a valid discount type. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;

        if (quantity<0)
        {
              cout << "Invalid Entry. Please enter the correct Quantity";
              system("pause");
              exit(0);
        }

        cout << "Would you like to perform another transaction? 'yes' or 'no'";
        cin >> multipleSales;
        transactionNumber++;
        }

return (itemID, quantity, discountType, itemPrice, transactionNumber);

}

Last edited on
closed account (o3hC5Di1)
Hi,

had to fix some stuff in your function declaration of saleRecord()

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double saleRecord(unsigned int &itemID, double itemPrice, char discountType, unsigned int quantity, double &transactionNumber);
double calculateItemCost(char discountType, double itemPrice, double finalPrice, int quantity);
void calcTotalPrice(double totalPrice, unsigned Num, bool aborted);
double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity);
double displayTotalPrice(double totalPrice);




int main()
{
    unsigned int itemID, quantity, records, totalQuantity;
    char discountType;
    double itemPrice, discount, transactionNumber, allPrices, totalPrice;

    int totalRec;
    saleRecord(itemID, itemPrice, discountType, quantity, transactionNumber); 
    calculateItemCost(discountType, itemPrice, totalPrice, quantity); 
    displayTotalPrice(totalPrice);


    //system("pause");
    return 0;
}

    void finalPrice(double finalPrice)
{
    cout << "The final price with all of the items is " <<finalPrice;
    return;
}

double calcItemPrice(double itemPrice, double totalPrice, char discountType, int quantity){
float discount;
switch (discountType){

              case 'N': discount=1;
              break;

              case 'n': discount=1;
              break;

              case 'B': discount=0.9;
              break;

              case 'b': discount=0.9;
              break;

              case 'D': discount=0.8;
              break;

              case 'd': discount = 0.8;
              break;

              case 'T': discount=0.7;
              break;

              case 't': discount=0.7;
              break;
       
              default: discount=1;
}
       totalPrice=itemPrice*discount*quantity;

       return totalPrice;
}
double saleRecord(unsigned int &itemID, double itemPrice, char discountType, unsigned int quantity, double &transactionNumber)
{
       int multipleSales = 0;
       cout << "Enter the 6 digit item ID starting with a number greater than 1:";
       cin >> itemID;
       if (itemID <=99999 || itemID >999999)
          {

                  cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
                  system("pause");
                  exit(0);
                  }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0)
           {
           cout << "You didn't enter a valid price. Try again.";
           system("pause");
           exit(0);
           }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
             cout << "You didn't enter a valid discount type. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;
        if (quantity<0)
        {
             cout << "You didn't enter a valid quantity sold. Try again.";
             system("pause");
             exit(0);
        }

        cout << "Would you like to perform another transaction? '1' for yes or '0' for no";
        cin >> multipleSales;
        transactionNumber++;


        while(multipleSales==1)
        {
        cout << "Enter the 6 digit item ID starting with a number greater than 1:";
        cin >> itemID;

        if (itemID <=99999 || itemID >999999)
        {
              cout << "You didn't enter a 6 digit item ID startin with a number greater than 1. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the price of the item:";
        cin >> itemPrice;

        if (itemPrice<0.1 || itemPrice > 9999999)
        {
              cout << "You didn't enter a valid price. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the discount type. The valid discount types are:\n\
        \aN: No discount\n\
        \aB: Basic discount (10%)\n\
        \aD: Double discount (20%)\n\
        \aT: Triple discount (30%)";
        cin >> discountType;

        if (discountType!='N' && discountType!='B' && discountType!='D' && discountType!='T')
        {
              cout << "You didn't enter a valid discount type. Try again.";
              system("pause");
              exit(0);
        }

        cout << "Enter the quanity of item sold.";
        cin >> quantity;

        if (quantity<0)
        {
              cout << "Invalid Entry. Please enter the correct Quantity";
              system("pause");
              exit(0);
        }

        cout << "Would you like to perform another transaction? 'yes' or 'no'";
        cin >> multipleSales;
        transactionNumber++;
        }

return (itemID, quantity, discountType, itemPrice, transactionNumber);

}



NwN
Last edited on
That fixed the errors I had but created these:
[Linker error] undefined reference to `calculateItemCost(char, double, double, int)'
[Linker error] undefined reference to `displayTotalPrice(double)'
ld returned 1 exit status
closed account (o3hC5Di1)
You haven't actually defined these functions, only declared and posibly called them, you need blocks like

1
2
3
4
double calculateItemCost(double price, double quantitiy)
{
    return price*quantity;
}


That's just an example, it won't work.

All the best,
NwN
It compiles now but the "final price" doesn't display as I wanted it to.
I'm so much trouble haha sorry.
closed account (o3hC5Di1)
Hi there,

Maybe it's because of this, not sure though - it depends on your intent:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main()
{
    unsigned int itemID, quantity, records, totalQuantity;
    char discountType;
    double itemPrice, discount, transactionNumber, allPrices, totalPrice;

    int totalRec;
    saleRecord(itemID, itemPrice, discountType, quantity, transactionNumber); 
    calculateItemCost(discountType, itemPrice, totalPrice, quantity); 
    displayTotalPrice(totalPrice); //here it's called displayTotalPrice(totalPrice)


    //system("pause");
    return 0;
}

    void finalPrice(double finalPrice) //here it's called finalPrice(finalPrice)
{
    cout << "The final price with all of the items is " <<finalPrice;
    return;
}
Topic archived. No new replies allowed.