Hello, I am new to C++ and just started learning functions. My problem is that when I run the program it asks me to enter the number of employees twice. Here is the code.
#include <iostream>
using namespace std;
int getEmployee();
int getDays();
//double getAverage(int, int);
int main()
{
int employee, totalMissed;
//double average;
cout<<"There are "<<employee<<" employees.\n";
cout<<"They missed a total of "<<totalMissed<<" days.\n";
//cout<<"The average number of days missed is "<<average<<".\n";
system("pause");
return 0;
}
int getEmployee()
{
int employee;
cout<<"Enter the number of employees.\n";
cin>>employee;
while (employee<1)
{
cout<<"There must be 1 or more employees.\n";
cin>>employee;
}
return employee;
}
int getDays()
{
int days, employee, count, totalMissed;
employee=getEmployee();
totalMissed=0;
for(count=1; count<=employee; count++)
{
cout<<"How many days did employee number "<<count<<" miss.\n";
cin>>days;
while(days<0)
{
cout<<"Employees can not miss less than zero days.\n";
cin>>days;
}
totalMissed+=days;
}
return totalMissed;
}
//double getAverage()
//{
//}
Ignore the commented part. The program is not done. I just need to get the double question fixed before I move on. I have been staring at the screen and flipping through my book for a while now. Any help would be greatly appreciated.