please help with this program

please help with this program. I need to calculate the highestSales, the averageSales using float funtions and displayOutput using void, I wrote the program but I can not get the output, I just started learning C++ programing and I get a lot of confusion. please help. when I'm trying to compile i get the error cpp:5
too few arguments to function `float getSales(float, float, float, float)'





#include <iostream>
using namespace std;

float getSales(float sales1, float sales2, float sales3, float sales4)
{
return (sales1 + sales2 + sales3 + sales4);
cout << "enter sales figure until 4: "<<endl;
cin >>sales1 >>sales2 >>sales3 >>sales4;
cout <<endl;

}

float findHighest(float sales1, float sales2, float sales3, float sales4)
{
return (sales1, sales2, sales3, sales4);
}
float calcAverage(float sales1, float sales2, float sales3, float sales4)
{
return (sales1 + sales2 + sales3 + sales4) /4;
}
void displayOutput (float highestSales, float averageSales)
{
cout.setf(ios::fixed);
cout.precision(2);
highestSales = 0;
averageSales = 0;
}

int main()
{
float sales1,
sales2,
sales3,
sales4;
float averageSales;
float highestSales;

for (int i = 0; i < 4; i++)
{
sales1 = getSales();
sales2 = getSales();
sales3 = getSales();
sales4 = getSales();

highestSales = findHighest(sales1, sales2, sales3, sales4);

averageSales = calcAverage(sales1, sales2, sales3, sales4);

displayOutput(highestSales, averageSales);
}
return 0;
}

When you declare your getSales function, you're specifying that it has four parameters; all floats.

When you call it in main, you're not passing in any parameters. I suspect, from looking at your code, that you're a little confused about parameters and return values.

Moreover, your getSales function won't actually do any of the process after the line that contains the return. It'll essentially return a an addition of whatever is passed in.

Note: Please use the code tags provided when posting code.
I want to write three float function one for getSales to ask the user for a sales figure and return the sale figure, another one for findHighest that passed the four sales figure, determine and return the highest sales figure, and another float function calcAverage that passed the four sale figure, determine and return the average sale figure.

And then a void function displayOutput that passed the highest sales figure and the average sales, and then display the highest sales figure and the average sales.

I wrote the program above but is not working, when compiling I get the error message error cpp:5 too few arguments to function `float getSales(float, float, float, float)'

Please can you explain what to change in the program

Last edited on
Topic archived. No new replies allowed.