i am trying to work on an assignment that asks me to prompt the user for a name of one of three employees, then prompt for the work hours of 6 days. each of these will be stored in a separate array.

then i am to implement the following rules into the program:

cannot work more than 10 hrs/day and if it does, it will only record 10 hrs and display a message informing the user.

and cannot have more than 3 overtime days, a regular day being 8 hrs. if someone tries to enter 4th OT day, program only records 8 hrs and will display a message.

i am having trouble figuring this out and was seeing if any of the more experienced programmers could help me out on this one. thanks alot.

8 Years
Discussion Span
Last Post by jonsca

do you have any code written already?

this is what i have so far.

using namespace std;

int main()
	char emp_name[3][34]={"Mary Vanilla","Kate Mocha","James   Chocolate"};
	int hours[7];
	int i=1;

	cout<<"Please enter the name of employee"<<"\n";
	cout<<"Please enter work hours for each day"<<"\n";
		cout<<"Day "<<i<<"\n";

return 0;


Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????


Where do the hours data for the first person go once you read in those of the second person? I would make that a 2D array also.

If you're going to read in a name with a space in it you won't be able to use cin. Use cin.getline() instead.

Use an while loop (or a for loop) around everything to step through the names and within that while loop use the one you have there to input the hours data.

int j = 0;
      Enter the name, etc.
      while(i<6) //only 6 days worth, start i at 0
              input hours
              if statements in here to check for overtime and too many OTs
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.