function does not take 0 arguments error. PLEASE HELP!

I keep getting the function does not take 0 arguments error. I have read a few other posts and sort of recognize where my problem is but I can't figure out how to fix it!!

Here's the program. I know this program can be written much easier but my instructor wants 3 functions (1 input, 2 calculation, 3 display)

#include "StdAfx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double calcsales(double);
double getsales(double);
char y;
double sales, comm;

int main()
{
while(sales = 1, sales > 0, sales ++)
{
getsales();
cout << "\nThe sales amount entered is: " << sales;
calcsales();
cout << "\nThe commission earned is : " << comm;
if(y)
break;
else
continue;
}


return 0;

}

double getsales()
{
cout << "Please enter the sales amount: ";
cin >> sales;

return sales;
}


double calcsales()
{
if(sales > 0 || sales <= 999)
comm = sales * 0.035;

else if(sales > 999 || sales <= 1999)
comm = sales * 0.04;

else if(sales > 1999 || sales <= 2999)
comm = sales * 0.045;

else if(sales > 2999)
comm = sales * 0.05;
else
cout << "\n Would you like to terminate the program?"
<< "\n Enter 'y' for yes or 'n' for no.";

return comm;
}


I get these 2 errors only:

error C2660: 'getsales' : function does not take 0 arguments
error C2660: 'calcsales' : function does not take 0 arguments
See this line of code here:
double getsales(double);
You promised the compiler that the function getsales takes a double.

getsales(); but here you try to call the function without passing in that double. Change what you promised the compiler.
You declared functions as taking one parameter

double calcsales(double);
double getsales(double);

However you call them without any argument

getsales();
calcsales();
Last edited on
OK that solved the problem, but now there's a new problem. When I run the program, it won't save the number I input for sales. It says the number that I entered was 2 no matter what number I put in and the math for the commission is calculated wrong and it's a different number every time I run the program.

Here is an example of the command prompt window:

Please enter in the sales amount: 100

The sales amount entered is : 2
The commission earned is: -4.47069e+134


And here is my revised program:

#include "StdAfx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double getsales();
double calcsales(double);
char y;
double sales, comm;

int main(double sales, double comm)
{
while(sales = 1, sales >= 0, sales ++)
{
getsales();
cout << "\nThe sales amount entered is: " << sales;
calcsales(sales);
cout << "\nThe commission earned is : " << comm;
if(y)
break;
else
continue;
}


return 0;

}

double getsales()
{
cout << "\nPlease enter the sales amount: ";
cin >> sales;

return sales;
}


double calcsales(double)
{
if(sales >= 0 && sales <= 999)
comm = sales * 0.035;

else if(sales > 999 && sales <= 1999)
comm = sales * 0.04;

else if(sales > 1999 && sales <= 2999)
comm = sales * 0.045;

else if(sales > 2999)
comm = sales * 0.05;
else
cout << "\n Would you like to terminate the program?"
<< "\n Enter 'y' for yes or 'n' for no.";

return comm;
}
Your function getsales returns a value. You are not doing anything with it. You are throwing it away. Here is how to store the returned value from a function:

1
2
double someVariable;
someVariable = getSales(); // now the variable named someVariable has the returned value from the function 


It works perfect now! Thank you very VERY much! You're AWESOME!!!
Topic archived. No new replies allowed.