Error c2660, function does not take 2 arguments

I'm writing a program the asks a painter to enter the number of rooms he needs to paint and then the length and width to calculate the sq ft and tell him how much to charge and how long it will take. I've gotten the code written out and my math is right, but when I go to compile I get the following error: "Error 1 error C2660: 'getArea' : function does not take 2 arguments" I've searched the internet and other forums and threads on here and tried to figure out which parameters to put into line 31 (the line Visual Studio 2013 says is wrong) and haven't yet been able to figure it out. If someone could look it over and steer me in the right direction as to whats wrong with my code it would be greatly appreciated.


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

const double PRICE_PER_HOUR = 38.99; // Cost of labor per hour
const double AREA_PER_HOUR = 14.375; // Amount of wall space area (sq ft) that can be painted per hour.

void getRooms(int& rooms);
int getArea(int area, int countPar, int length, int height);
void displayError();
int addArea(int totArea, int area);
double calculateHours(double rate, int area);
double calculateCost(double rate, double hours);
void displayHours(double hours);
void displayCost(double cost);

int main()
{
	int dummy_int;

	int numberOfRooms = 0,
		totalRooms = 0,
		totalArea = 0,
		count = 0;
	double hoursOfLabor = 0.0,
		costOfLabor = 0.0;

	getRooms(numberOfRooms);

	for (count = 1; count <= numberOfRooms; count++)
	{
		totalRooms = getArea(totalRooms, count);

		if (totalRooms <= 20)
		{
			totalArea = addArea(totalArea, totalRooms);
		}

		else
		{
			displayError();
		}
	}

	hoursOfLabor = calculateHours(AREA_PER_HOUR, totalArea);
	costOfLabor = calculateCost(PRICE_PER_HOUR, hoursOfLabor);
	displayHours(hoursOfLabor);
	displayCost(costOfLabor);
	cin >> dummy_int;
}

void getRooms(int& rooms)
{
	cout << "Please enter the number of rooms to be painted: ";
	cin >> rooms;
}

int getArea(int area, int countPar, int length, int height)
{
	cout << "Please enter the height for room #" << countPar << " (in ft) : ";
	cin >> height;
	cout << "Please enter the length for room #" << countPar << " (in ft) : ";
	cin >> length;
	area = length * height;
	return area;
}

int addArea(int totArea, int area)
{
	return totArea + area;
}

void displayError()
{
	cout << "Number of rooms must be less than or equal to 20, please try again." << endl;
	return;
}

double calculateHours(const double rate, int area)
{
	return area / rate;
}

double calculateCost(const double rate, double hours)
{
	return hours * rate;
}

void displayHours(double hours)
{
	cout << "Total hours of labor required: " << hours << " hours." << endl;
	return;
}

void displayCost(double cost)
{
	cout << "Total cost of labor: $" << cost << endl;
	return;
}
int getArea(int area, int countPar, int length, int height); // takes 4 arguments

totalRooms = getArea(totalRooms, count); // But you are only giving it 2
Last edited on
Okay so I got the arguments problem fixed, and thank you for your help TarikNeaj, but now I have a new problem. I re-read my instructions and saw I missed a step in that I was supposed to ask for the length and height of each wall, not the room itself. So I went in and added what I thought would make it work, but now I'm getting an "Error 1 error LNK2019: unresolved external symbol "int __cdecl getArea(int,int,int,int)" (?getArea@@YAHHHHH@Z) referenced in function _main" followed by an "Error 2 error LNK1120: 1 unresolved externals" I haven't been able to find anything that truly describes my problem. Below is the new function I wrote for my getArea function:

1
2
3
4
5
6
7
8
9
10
11
12
int getArea(int area, int countPar, int length, int height, int numWalls)
{
	cout << "Please enter the height for room #" << countPar << " (in ft) : ";
	cin >> height;
	cout << "Please enter the length for room #" << countPar << " (in ft) : ";
	cin >> length;
	cout << "Please enter the number of walls for room #" << countPar << endl;
	cin >> numWalls;
	area = length * height * numWalls;
	cout << "Total Area for room #" << countPar << " is " << area << "sq ft.";
	return area;
}


if I delete the int numWalls and get ride of the line that asks the user for that, the program runs fine.

also here is my updated main, everything else is the same from my previous post:

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
int main()
{
	int dummy_int;

	int numberOfRooms = 0,
		totalRooms = 0,
		totalArea = 0,
		count = 0;
	double hoursOfLabor = 0.0,
		costOfLabor = 0.0;

	getRooms(numberOfRooms);

	for (count = 1; count <= numberOfRooms; count++)
	{
		totalRooms = getArea(totalRooms, count, totalArea, numberOfRooms);

		if (totalRooms <= 20)
		{
			totalArea = addArea(totalArea, totalRooms);
		}

		else
		{
			displayError();
		}
	}

	hoursOfLabor = calculateHours(AREA_PER_HOUR, totalArea);
	costOfLabor = calculateCost(PRICE_PER_HOUR, hoursOfLabor);
	displayHours(hoursOfLabor);
	displayCost(costOfLabor);
	cin >> dummy_int;
}


I've run out of ideas as to how to fix this dilemma, and further help is appreciated.

Update: I tried making a second function to be called within my getArea function, but instead of calling the new function I made, it went to my displayError function. Not sure how I managed to pull that off.
Last edited on
Your function prototype specifies that the function takes 4 arguments, and main calls it as if it takes 4, but your new definition takes 5. This means the linker can't find this function you said existed in your prototype.
Topic archived. No new replies allowed.