the program below is what i have...it compiles and runs but the problem is when it runs it asks Enter the number of employees which is fine but then it asks Enter days missed which is also find but it should calculate the average days missed but it keeps returning the message enter days missed....iwhat do i do from here??? please help ASAP

#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

int getnumemployees();
int getdaysmissed(int num_employees);
double getdaysmissedavg(int num_employees,int days_missed);

int main ()
{

    int number_of_employees=0;
    int totaldaysmissed=0;
    double average_days_missed=0;

    number_of_employees=getnumemployees();
    totaldaysmissed = getdaysmissed(number_of_employees);
    average_days_missed = getdaysmissedavg(number_of_employees,totaldaysmissed);
    return 0;
}

int getnumemployees()
{
    int numemployees=0;
    
    cout<<"Enter the number of employees: "<<endl;
    cin>>numemployees;
    return numemployees;
}

int getdaysmissed(int num_employees)
{
    int daysmissed=0;
    int totaldaysmissed = 0;
    
    while (num_employees>=1)
    {
    cout<<"Enter days missed: "<<endl;
    cin>>daysmissed;
    totaldaysmissed += daysmissed;
    num_employees--;
}

     return daysmissed;
}

double getdaysmissedavg(int num_employees, int days_missed)
{
    int numemployees=0;
    int daysmissed=0;
    double daysmissedavg=0;
      
    daysmissedavg=numemployees/daysmissed;
    cout<<"Calculate the average number of days absent "<<daysmissedavg;
    
    system("pause");
 return 0;   
}

`

Please, use code tags when you post code.

See the comments ...

double getdaysmissedavg(int num_employees, int days_missed)
{
	int numemployees=0;
	int daysmissed=0;
	double daysmissedavg=0;

        // every time you call this function, you effectively calculate 
        // '0/0' which results in error (you must not divide by zero)
        // shouldn't you be using this function's parameters instead??
	daysmissedavg=numemployees/daysmissed;
	cout<<"Calculate the average number of days absent "<<daysmissedavg;

	system("pause");

        // then you'll probably want to return the calculated value
        //  'daysmissedavg' instead of zero ...
	return 0;
}
int getdaysmissed(int num_employees)
{
int daysmissed=0;
int totaldaysmissed = 0;

while (num_employees>=1)
{
cout<<"Enter days missed: "<<endl;
cin>>daysmissed;
totaldaysmissed += daysmissed;
num_employees--;
}

//!!!The function should return totaldaysmissed instead of daysmissed!!!

return daysmissed;  
}

And how many employees did you enter? Because the program should ask to enter days missed as many times as many employees are.

oh ok thanks alot....so say i have 3 employees....it is just going to ask how many days missed 3 times....then thats it? since it is supposed to calculate the average without output or user input? so does hat program calculate the average also?

it is not calculating the correct average....

it is not calculating the correct average....

Post your updated code, formatted and with code tags, explain exactly what the program is SUPPOSED to do and explain exactly what the program is doing that is incorrect. Tell us what input you have entered and what the desired output should be.

Also, I don't know what this means. To calculate the average, you need input.

since it is supposed to calculate the average without output or user input? so does hat program calculate the average also?

Listen, correct your code: correct the getdaysmissedavg() and the getdaysmissed() function as it is showed in the replies:

double getdaysmissedavg(int num_employees, int days_missed)
{
	double daysmissedavg=0;
	daysmissedavg=num_employees/days_missed;
	cout<<"Calculate the average number of days absent "<<daysmissedavg;

	system("pause");
	return daysmissedavg;
}

Here, the first two variables are completely unnecessary: numemployees and daysmissed.
And here is the other function:

int getdaysmissed(int num_employees)
{
int daysmissed=0;
int totaldaysmissed = 0;

while (num_employees>=1)
{
cout<<"Enter days missed: "<<endl;
cin>>daysmissed;
totaldaysmissed += daysmissed;
num_employees--;
}

return totaldaysmissed;

I think it should work now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.