0

I keep on getting the erro "error C2064: term does not evaluate to a function taking 1 arguments" I have three of these errors and they are all on the first line after the if statements. I really dont know what is going wrong. Been working on this error for about 2 hours now. Please help!!

Attachments
#include "stdafx.h"

float residential_rate(float consumption);
float commercial_rate(float consumption);
float industrial_rate(float consumption);

int _tmain(int argc, _TCHAR* argv[])
{
	char property_code, R, I, C;
    float residential_rate, commercial_rate, industrial_rate, account_number, consumption, total;

	printf("Enter property code: ");
	scanf("%c", &property_code);

	printf("Enter your account number: ");
	scanf("%f", &account_number);

	printf("Enter consumption rate KW/hour: ");
	scanf("%f", &consumption);
	
	if (property_code == 'R') {
		total = residential_rate(consumption);
		printf("Your total for the month is: $%.2f", total);
	}
	else if (property_code == 'C') {
		total = commercial_rate(consumption);
		printf("Your total for the month is: $%.2f", total);
	}
	else if (property_code == 'I') {
		total = industrial_rate(consumption);
		printf("Your total for the month is: $%.2f", total);
	}
	else {
		printf("You have entered and invalid Propertey Code!!");
	}
	getchar();
	getchar();
	return (0);
}
float residential_rate(float consumption)
{
	float total;
	total = 6 + (0.069 * consumption);
	return total;
}
float commercial_rate(float consumption)
{
	float total;
	if (consumption > 1000)	{
		total = 69 + ((consumption - 1000) * 0.049);
	}
	else
	{
		total = 69;
	}
	return total;
}
float industrial_rate(float consumption)
{
	float total;
	total = 69 + (0.049*consumption);
	return total;
}
3
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by zac_haryy
0

you can not use the name of functions as the name of a variables. Function names must be different from variable names. Example: residential_rate is used both as a function name and a variable name, and since the variable name is in _tmain() the compiler is treating that symble as a float, not a function.

1

You are declaring functions residential_rate(), commercial_rate(), industrial_rate() also as floats of the same name in function main(). Remove those variables and it will work!

Oops, I was too slow! Sorry Mister Dragon near St Louis!

Votes + Comments
Helps-[Grunt]
0

Everything worked great after taking the functions out of the identifier. Thanks!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.