Hey guys I'm a Newb (TAKING MY 1ST C PROGRAMMING CLASS AT A UNIV.) I REALLY need help with this, it's printing and counting but it's counting too far, it's supposed to stop at 4:0:3 and then break and then count again. and then it doesn't include the "Do you want to have lunch" inside the loop, it just reverts back to the breakfast.... I've been at this thing for 3 DAYS and STILL no progress.. what am I doing wrong??? would really appreciate the help
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define hrs 20
#define sec 15
#define min 12
Code:
int main(void)
{
int total_sec;
int set_time;
int start_timer;
int quit;
int h=0,m=0,s=0;
int yes;
int no;
int choice;
int i,j,k;
int ch,cm,cs;
int cnt=0;
for(;;)
{
printf(" Choose one of the following menu options:\n");
printf("1: set_time\n");
printf("2: start_timer\n");
printf("3: quit\n");
scanf("%d", &choice);
switch(choice)
{
case 1: printf("what is the current time?\n");
scanf("%d:%d:%d",&h,&m,&s);
break;
case 2: printf("how long would you like me to count?\n");
scanf("%d:%d:%d",&ch,&cm,&cs );
printf("HERE WE GO!\n");
printf("\n");
total_sec=(ch*hrs)+(cm*sec)+(cs);
//printf("\n%d\t%d\t%d\t%d\n",ch, cm, cs, total_sec);
for(i=0;i<total_sec;i++)
{
printf("%d:%d:%d\n",h,m,s);
s++;
if(s==sec)
{
s = 0;
m++;
if(m==min)
{
m=0;
h++;
}
}
case 3: printf("Have you had your breakfast yet?\n");
printf("1: yes\n");
printf("0: no\n");
scanf("%d", &choice);
if(choice==1);
{
printf("Good\n");
}
else printf("Done Counting!\n");
break;
case 4: printf("Have you had your lunch yet?\n");
printf("1: yes\n");
printf("0: no\n");
scanf("%d", &choice);
if(choice==0);
{
printf("You have %d%d%d till the end of lunch time!\n");
}
else printf("Good!\n");
break;
case 5: printf("Thank You!\n");
}
break;
printf("Sorry, that is not a valid menu choice.\n");
}
return 0;
}
I'm not asking for anybody to do my work for me, just tell me what I need to fix and some suggestions...Here's what the criteria is..
How long would you like me to count?
0:1:0 //what the user puts in//
HERE WE GO!
3:11:13
3:11:14
4:0:0
4:0:1
4:0:2
4:0:3
Have you had your breakfast?
1: Yes
0: No
1
Good!
4:0:4
4:0:5
4:0:6
4:0:7
4:0:8
4:0:9
4:0:10
4:0:11
4:0:12
DONE COUNTING!
Choose one of the following menu options:
1: set time
2: start timer
3: quit
1
What is the current time?
7:10:0
Choose one of the following menu options:
1: set time
2: start timer
3: quit
2
How long would you like me to count?
0:1:5
HERE WE GO!
7:10:0
7:10:1
7:10:2
7:10:3
7:10:4
7:10:5
7:10:6
7:10:7
7:10:8
7:10:9
7:10:10
7:10:11
7:10:12
7:10:13
7:10:14
7:11:0
7:11:1
7:11:2
Have you had your lunch?
1: Yes
0: No
0
You have 1:0:13 till the end of lunch time.
7:11:3
7:11:4
DONE COUNTING!
Choose one of the following menu options:
1: set time
2: start timer
3: quit
1
What is the current time?
19:11:10
Choose one of the following menu options:
1: set time
2: start timer
3: quit
2
How long would you like me to count?
0:0:8
HERE WE GO!
19:11:10
19:11:11
19:11:12
19:11:13
19:11:14
0:0:0
0:0:1
0:0:2
DONE COUNTING!
Choose one of the following menu options:
1: set time
2: start timer
3: quit
4
Sorry, that is not a valid menu choice.
Choose one of the following menu options:
1: set time
2: start timer
3: quit
3
Thank you.