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.

Recommended Answers

All 4 Replies

do you have any code written already?

do you have any code written already?

this is what i have so far.

#include<iostream>
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";
	cin>>emp_name[0];
	cout<<"Please enter work hours for each day"<<"\n";
	while(i<7)
	{
		cout<<"Day "<<i<<"\n";
		cin>>hours[i];
		++i;
	}

return 0;

}

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;
while(j<3)
{
      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
      }
}
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.