Urgent help needed

Lately i have been working on a program which lets employees clock in and clock out in the work place.I want 10 employees to be able to clock in when they arrive to work and clock out when they finish .I have attempted it but cant get my head around the loops and arrays.Each employee is paid $25 per hour but must be paid for excess minutes also.the time they work must be calculated by subtracting the clock in time from the clock out time..when the program is run the employee is greeted by a menu whuch allows them to Clock in , Clock out or Exit.


I would like to be able to enter the times manually

When exit is chosen by the employee a report is generated and displayed.The report will list the name of the ten employee with their pay for the day and the total amount of money earned by employees. If an employee did not clock in the word absent should appear alongside their name.



Any help or advice would be great as im quite new to C++ and trying to learn and advance in it ...
Last edited on
This is all i have so far and im lost


#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<string>

using namespace std;

#define noEmployees 10

string employeeNames[noEmployees];

void getEmployees();


int main () {

getEmployees ();



getch();
return 0;

}


void getEmployees () {

// Gets the employee names from the employees.txt file and puts them into the
// employeeNames array

ifstream employeeFile;

employeeFile.open ("employees.txt");

for (unsigned short i = 0; i<= noEmployees -1; i++)
getline(employeeFile, employeeNames[i], '\n');

employeeFile.close ();
}

void printEmployees () {
// Print out the names of the 10 employrrs

for (unsigned short i = 0; i<=noEmployees-1; i++)
cout << employeeNames[i] << endl;
cout<<endl;
}


void countpay () {

//Counts the employees individual pay

unsigned short rate=25;
unsigned short hours=0;

for(unsigned short i = 0; i<=noEmployees-1; i++)

do {
(out-in)*25=pay
cout<<"your pay for the day is $"<<pay<<endl;
}




//Display menu
cout<<"*****************************"<<endl;
cout<<"1) clock in."<<endl;
cout<<"2) clock out."<<endl;
cout<<"3) exit."<<endl;
cout<<"*****************************"<<endl;
cin>>choice;



if
{(Choice==1)

cout<<"good morning please enter your clock in time"<<endl;
cin>>in

else if
(choice==2)
cout<<"Please enter your clock out time"<<endl;
cin>>out
else if
(choice==3)
cout<<"press and key to terminate the program"<<endl;
cin>>print
else
cout<<"that is an invalid key"<<endl;



Last edited on
To start the display menu function should have some sort of header.

1
2
3
4
5
6
7
8
9
10
11
12
13
void countpay () {

//Counts the employees individual pay

unsigned short rate=25;
unsigned short hours=0;

for(unsigned short i = 0; i<=noEmployees-1; i++)

do {
(out-in)*25=pay
cout<<"your pay for the day is $"<<pay<<endl;
}


This code needs a variable like maxHours to determine when to pay overtime. If your not paying overtime but would still like to show how much more they earned than a regular days pay you would still need a value to represent a "regular" work day.

if you know how to work with structures this would be a good place to use one.
example:
1
2
3
4
5
struct employee
{
     empName[amtEmployees];
     empHours[amtEmployees,2];//second dimension to hold total pay    
};


if your not familiar with structs you could just define two array's and use one index variable to move through them.

I would suggest using a switch statement for you clock in clock out menu and then calling the appropriate functions.

Unless you plan on writting your own time function i would #include <ctime>


Hope this helps and is fairly accurate.




Thanks ya the menu should be easy enough should it?
Haven't looked at structures yet atal so i would be out of my comfort zone using them..
also im planning on reading in the time from a system clock not manually here is the code for that..

#include <iostream.h>
#include <conio.h>
#include <time.h>
#include <string>

int main (void) {

   char theTime[9];
   string clockTime = _strtime (theTime);
   getch ();
   return 0;
   }
Topic archived. No new replies allowed.