# Thread: Any assistance would be greatly appreciated

1. ## Any assistance would be greatly appreciated

Code:
```//Jonathan Barnwell
//COP 3223 Section 1
//Program III
//02/23/06

#include <stdio.h>

#define HRS_DAY 20 //define hours per day
#define MINS_HR 12 //define minutes per hour
#define SECS_MIN 15 //define seconds per minute

int main(void)	{

int h = 0, m = 0, s = 0; //current time
int hT, mT, sT; //count time

do	{
printf("Choose one of the following menu options:\n");
printf("1: set time\n");
printf("2: start timer\n");
printf("3: quit\n");

printf("What is the current time?\n");
scanf("%d:%d:%d", &h, &m, &s);
}
else if (menu_choice == 2)	{
printf("How long would you like me to count?\n");
scanf("%d:%d:%d", &hT, &mT, &sT);
//I am supposed to take every second and print it until that interval expires
}
else if (menu_choice == 3)	{
printf("Thank you.\n");
}
else	{
printf("Sorry, that is not a valid menu choice.\n");
}

return 0;
}```
The whole event takes place on mars, so you can see the different time intervals for minutes, hours and days respectevely at the top.

I'm supposed to create a menu for the user, (set time/start timer/quit)

as you can see, most of that is already input.

next i am to take the current time and print in seconds until the interval provided expires. (for example using EARTH, if its 2:00:00 and he wants me to count for an hour i'm supposed to print every second until three a clock.)

i hope that makes sense

i don't know how to continue from here

Michael

PS theres more to it, i'm just trying to understand it step by step

2. Looks like you need a loop. You'll need to think about how a clock works, and duplicate that process. Surely you've got some idea how a clock works. Let's see you give it a shot.

Quzah.

3. convert total time in interval to seconds

add seconds to original time incrimenting minutes and hours when necessary but how?

i'm not asking for a complete solution, just something to point me in a better direction compared to what i have now.

4. What happens on a clock when it reaches 59 seconds and needs to increment? Quite obvious, really.

5. i understand the logic behind what is asked of me, the only problem is the mental leap of being able to explain it to the computer.

this is my first year in C so i'm still learning

6. Since you're using #defines
Code:
```#define HRS_DAY 20 //define hours per day
#define MINS_HR 12 //define minutes per hour
#define SECS_MIN 15 //define seconds per minute```
why not change them to "Earth" for development and initial debugging, and then later change them back?

8. Code:
```total = (hT * MINS_HR * SECS_MIN) + (mT * SECS_MIN) + (sT);
printf("HERE WE GO!\n");
while (total > 0){
printf("%d:%d:%d", h, m, s);
if (s == SECS_MIN)	{
m = m +1;
s = 0;
}
if (m == MINS_HR)	{
h = h + 1;
m = 0;
}
if (h == HRS_DAY)	{
h =0;
}
total = total - 1;
}```
You will keep on printing same values of h,m,s.
You have to increment s in while loop.otherwise your If statements will not work the way you want it.

9. i appreciate your reply, everything seems to be working now except rolling over to the next day..which i will fix

10. Gotta increment your seconds in that, Tonto. Also, don't forget, that code's "second" is the time it takes to loop. In otherwords, rediculously fast. You'll need to use a sleep function if you want proper speed.

Code:
```printf("%d:%d:%d\n", h, m, s);
s++;
if (s == 60)	{```

11. Code:
```else if (menu_choice == 2)	{ //begin menu choice 2
printf("How long would you like me to count?\n");
scanf("%d:%d:%d", &hT, &mT, &sT);
total = (hT * MINS_HR * SECS_MIN) + (mT * SECS_MIN) + (sT);
Bt = total - breakfast;
Lt = total - lunch;
Dt = total - dinner;
printf("HERE WE GO!\n");
while (total > 0)	{
printf("%d:%d:%d", h, m, s);
s = s + 1;
if (s == SECS_MIN)	{
m = m +1;
s = 0;
}
if (m == MINS_HR)	{
h = h + 1;
m = 0;
}
if (h == HRS_DAY)	{
h = 0;
}
total = total - 1;
printf("\n");
}
User inputs start time and amount of time wanted to count for. I'm required to remind the user to eat breakfast between 4:00:00 and 5:00:00

i already have a random number for the amount of seconds in the breakfast break interval, Bt.

12. Code:
```while (total > 0) {
printf("%d:%d:%d", h, m, s);
s = s + 1;
if (s == SECS_MIN) {
m = m + 1;
s = 0;
}
if (m == MINS_HR) {
h = h + 1;
m = 0;
}
if (h == HRS_DAY)
h = 0;
total = total - 1;
if (total == Bt)
printf("\nIt's breakfast time!");
printf("\n");
}```

14. Well I can only assume with the variable breakfast contains. So I can't write you exact statement. By the way, when people write this code, it's not for you to copy and paste, it's for you to learn from.

15. my fault i mis-understood your intentions, i will continue working at it and i appreciate your help.