Hello, I am trying to work on a program which is like this: There are several offices and each office is open on different times on different days. User inputs desired day and time and I have to return every office which is open on day and time user provided.

For example:
Office 1 hours: Monday: 9am to 1pm & 2pm to 5pm, Tuesday: 9am to 5pm, Wednesday: 9am to 11am, 1pm to 3pm, & 4pm to 6pm, Thursday: closed, Friday: closed, Saturday: closed, Sunday: closed
Office 2 hours: Monday: 10am to 3pm, Tuesday: 9am to 2pm & 3pm to 6pm, Wednesday: 9am to 6pm, Thursday: 9am to 4:30pm, Friday: 8am to 4pm, Saturday: closed, Sunday: closed
Office 3 hours: Monday: closed, Tuesday: 8am to 1pm & 2pm to 5pm, Wednesday: closed, Thursday: 1pm to 5pm, Friday: 8am to 1pm & 2pm to 6pm, Saturday: 10am to 1pm & 2pm to 5pm, Sunday: 9am to 3pm
Office 4 hours: Monday: closed, Tuesday: closed, Wednesday: closed, Thursday: closed, Friday: 8am to 6pm, Saturday: 8am to 6pm, Sunday: 8am to 10am, 11am to 1pm, 3pm to 5pm
Office 5 hours: Monday: 8am to 5pm, Tuesday: 8am to 5pm, Wednesday: 8am to 5pm, Thursday: 8am to 5pm, Friday: 8am to 5pm, Saturday: closed, Sunday: closed

And now user inputs Saturday 3:30pm so now my program should give him list of Office 3 and Office 4

I am not sure how can I store all those hours into program, can anyone guide me? I just need idea then I can code.

I was thinking to change all those hours to seconds so it will be easy for me to compare if usertime falls in hours offices are open. But still am not sure how can i store hours when offices are open.

Once I have hours stored, I am planning to do following

checkUserTime(string, int, int) // string for day, int for hours and 2nd int for mins
{
convert hours into seconds
convert mins into seconds
add all seconds and compare with stored hours
if (string == "Monday") then check with monday hours of all offices
if (string == "Tuesday") then check with tuesday hours 
etc...

Thanks in advance

Recommended Answers

All 3 Replies

Can you use an array of boolean values? See where you can go with that, or if that's not really what the professor intended then see if you can rework it.

Can you use an array of boolean values? See where you can go with that, or if that's not really what the professor intended then see if you can rework it.

How can I use an array here? Can you please explain am not sure

Think of a desktop calendar. It's got a grid, with each of the days across the top, and for each of those days there's a block for each hour. You shade in the blocks that are taken. If the block is shaded, it's a true value, if not, it's false. Sorry if I'm being telegraphic, but I don't want to take away from your own process through the problem.

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.