Undeclared use this function

Getting the following errors:
Line 62 REGULAR_PRICE_PER_SHIRT undeclared [first use this function]
Line 67 Expected '.'expected "cout"

I have checked everything. I think it may be a logic error.


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

int main()
{
	//Variables for cost and amount charged
	double numberofshirts, pricepershirt, totalprice, totalcost;
	
	// Constants for regular price of shirt
	const double REGULAR_PRICE_FOR_SHIRT = 12.00;
	//Get the number of shirts the customer will be buying.
	cout<<"How many shirts would you like?" <<endl;
	cin>> numberofshirts;
	
	//Set the desired output formatting for numbers
	cout<< setprecision(2) << fixed << showpoint;
	
	//Calculate and display cost per shirt and total cost.
	
	if (numberofshirts>=5 && numberofshirts<=10) // 5-10 shirts are 10 pct off
	{
	pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT*0.10);
	totalprice= numberofshirts*pricepershirt;
	cout<< "The cost per shirt is $" << pricepershirt << " and the total cost" <<
	"is $" << totalprice << endl;
    }

	 else if (numberofshirts>=11 && numberofshirts<=20) // 11-20 15 pct off
	 {
	 pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.15);
	 totalprice = numberofshirts*pricepershirt;
	 cout<< "The cost per shirt is $" << pricepershirt << " and the total "<<
	 "cost is $" << totalcost << endl;
 }
	 else if (numberofshirts>=21 && numberofshirts<=30) // 21-30 are 20 pct off
	 {
	 pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.20);
	 totalprice = numberofshirts*pricepershirt;
	 cout<< "The cost per shirt is $" << pricepershirt << " and the total "<<
	 "cost is $" << totalprice << endl;
 }
	 else if (numberofshirts>=31) // 31 or more are 25 pct off
	 {
	 pricepershirt = (REGULAR_PRICE_FOR_SHIRT - REGULAR_PRICE_FOR_SHIRT * 0.25);
	 totalprice = numberofshirts*pricepershirt;
	 cout<< "The cost per shirt is $" << pricepershirt << " and the total "<<
	 "cost is $" << totalprice << endl;
 }
	 else if (numberofshirts > 0 && numberofshirts< 5)// no discount
	 {
	 totalprice = (REGULAR_PRICE_PER_SHIRT * numberofshirts);
	 cout<< "The cost per shirt is $" << REGULAR_PRICE_PER_SHIRT <<
	  cout << " and the total cost is $" << totalprice << endl;
  }
	  else (numberofshirts < 0)
	  cout<< "Invalid input: Please enter a non-negative integer" << endl;
	  return 0;
  }
Are REGULAR_PRICE_PER_SHIRT and REGULAR_PRICE_FOR_SHIRT supposed to be the same?
else (numberofshirts < 0)
is not valid.
use
else
Actually just want it to show that REGULAR_PRICE_PER_SHIRT is $12.00 and multiply that to numberofshirts so it shows a total price.

Yes, thank you EssGeEich, else worked for that error.
Actually just want it to show that REGULAR_PRICE_PER_SHIRT is $12.00 and multiply that to numberofshirts so it shows a total price.


Yes, I see that.

I'm saying that REGULAR_PRICE_PER_SHIRT and REGULAR_PRICE_FOR_SHIRT are supposed to be the same thing. You wrote "PER" in the last else if statement when you meant to write "FOR". REGULAR_PRICE_PER_SHIRT appears nowhere else in you code which is why it is undeclared.

Change REGULAR_PRICE_PER_SHIRT to REGULAR_PRICE_FOR_SHIRT and your code should work.
Topic archived. No new replies allowed.