I'm new to c, and for my assignment we have to calculate how much money to charge using a function. However, I keep getting "undefined reference to `Calculate_charge'" whenever I try to call the function. what exactly am I doing wrong here?
#include <stdio.h>
double Calculate_charge(double y);
int main(void)
{
int customer;
double charge = 0;
int kwh;
double totalcharge;
int totalkwh;
int totalcustomer;
unsigned int count;
customer = 0;
kwh= 0;
totalcharge = 0;
totalkwh = 0;
totalcustomer = 0;
count = 0;
printf( "%s","Enter customer number (-1 to quit):\n");
scanf("%d", &customer);
printf("%s", "Enter kwh used (-1 to quit):\n");
scanf("%d", &kwh);
while (customer != -1 && kwh != -1) {
Calculate_charge(charge);
printf( "Customer Num: %d\n", customer);
printf("KWH used: %d\n", kwh);
printf("Charge: %.2f\n", charge);
count++;
totalcustomer++;
totalcharge = totalcharge + charge;
totalkwh = totalkwh + kwh;
printf( "%s","Enter customer number (-1 to quit):\n");
scanf("%d", &customer);
printf("%s", "Enter kwh used (-1 to quit):\n");
scanf("%d", &kwh);
}
double Calculate_charge(double y)
{
if (kwh <= 300) {
y = .09 * kwh;
}
else if (kwh > 300 && kwh <= 600){
y = .08 * kwh;
}
else if (kwh > 600 && kwh <= 1000){
y = .06 *kwh;
}
else {
y = .05 * kwh;
}
return y;
}
if (count != 0) {
printf("\n");
printf("Total customers:%d\n", totalcustomer);
printf("Total KWH used: %d\n", totalkwh);
printf("Total Charged: %.2f" , totalcharge);
}
}