Thread: Average

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    1

    Average

    Code:
    Hello,
    
    I have a question. i have to write a program that cvalculates the average number of days a company's employees are absent. The program should have the following functions:
    
    A functcion called by main that asks teh user for the number of employees in the company. this value should be returned as an int. (no parameters)
    
    A function called by main that accepts one argument: the number of employees in the company. the function should ask the user to enter the number of employees in the company. The function should ask teh user to enter the number of days each employee missed during the past year. The total of these days should be returned as an int.
    
    A function called by main that takes two parameters: the number of employees in the company and the total number of days absent for all employees during the year. The function should return as a double, the average number of days absent. (this function does not perform any screen output and does not ask the user for input.
    
    Can anyone help i am getting many errors ...
    
    the program i have so far is
    
    #include <iostream>
    #include <stdlib.h>
    #include <math.h>
    using namespace std;
    
    	int    getnum_employees=0;
    	int    total_days_missed=0;
    	double days_missed_average;
    
    int main ()
    {
    
            cout<<"Please enter the number of employees"<<endl;
            cin>>getnum_employees;
        
            return getnum_employees;
    }
    
    int getdays_missed (getnum_employees)
    {
                              while (num_employees>=1)
                           {
        	               cout<<"Please enter days missed"<<endl;
        	               cin>>getdays_missed;
        	
                           total_days_missed += getdays_missed;
        	               num_employees--;
    }
    
         return getdays_missed;
    }
    
         double getdays_missed_average(getnum_employees, getdays_missed)
    {
                    days_missed_average = getdays_missed/num_employees;
    	            cout<<"Average days missed: "<<days_missed_average;
    	            system("pause");
    return 0;
    }

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    3 things comes to mind:
    PLEASE don't put comments inside the code tags. Put them OUTSIDE. The code tags is for just that - code.
    2) Indentation is messed up, needs work. Otherwise code is poorly readable.
    3) Your understanding of the language is totally wrong. You need to re-read your books before attempting to create a project.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    So what are you having trouble with?

    And on a side note - dont use global variables. Keep them local in the created function and pass
    them by value/reference when needed
    Double Helix STL

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Winterx - if you think reporting your own post to the moderators will get us to rush to your post and help you, then you are mistaken.

    Reporting to the Mods is for issues that need dealing with immediately, not stupid stuff like this

    THREAD CLOSED

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 12:33 PM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  4. Average score
    By wiz23 in forum C++ Programming
    Replies: 22
    Last Post: 05-05-2005, 05:38 AM
  5. Creating a student grade book-how?
    By Hopelessly confused in forum C Programming
    Replies: 5
    Last Post: 10-03-2002, 08:43 PM