-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program1.C
67 lines (59 loc) · 2.07 KB
/
Program1.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/////////////////////////
// //
//Programming by NUBB.1//
// //
/////////////////////////
#include <stdio.h>
#include <string.h>
int main()
{
int age,hour,min;
char name[20],sex,married;
do
{
printf("\nPlease enter your name (type STOP to END): ");
scanf("%s",&name);
if (strcmp(name,"STOP")==0)
{
printf("Good Bye!\n");
break;
}
printf("changeB1");
do
{
printf("Please enter your age, gender (M/F), and are you married (Y/N): ");
scanf("%d %c %c",&age,&sex,&married);
if ((age<1 || age>120)||(sex!='M' && sex!='F')||(married!='Y' && married!='N'))
{
printf("Incorrect age (1-120) or gender (M/F) or married(Y/N), try again.\n");
}
}
while ((age<1 || age>120)||(sex!='M' && sex!='F')||(married!='Y' && married!='N'));
//printf("Please enter your age, gender (M/F), and are you married (Y/N): ");
//scanf("%d %c %c",&age,&sex,&married);
printf("changeB1");
do
{
printf("Enter hours (0-23) & minutes(0-59): ");
scanf("%d %d",&hour,&min);
if ((hour>=0 && hour<=23)&&(min>=0 && min <=59))
{
if(hour>=0 && hour<=11) printf("Good Morning, ");
else if(hour>=12 && hour<=18) printf("Good Afternoon, ");
else printf("Good Evening, ");
if(sex=='M' && age>=15) printf("Nai ");
else if(sex=='M' && age<15) printf("Dek Chai ");
else if(sex=='F' && married=='Y') printf("Nang ");
else if(sex=='F' && age>=15) printf("Nang Sao ");
else if(sex=='F' && age<15) printf("Dek Ying ");
printf("%s",name);
}
else printf("Incorrect hours (0-23) or minutes (0-59), try again.\n");
}
while((hour<0 || hour>23)|| (min<0 || min>59));
}
while(strcmp(name,"STOP")!=0);
printf("changeA1");
printf("changeA2");
return 0;
}