-
Notifications
You must be signed in to change notification settings - Fork 1
/
week12_function.c
74 lines (61 loc) · 1.67 KB
/
week12_function.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
68
69
70
71
72
73
74
/*
Chi phi:
- Phi noi tru: 150.000 vnd/ngay
- Tien thuoc: gia tri nguyen duong, lon
- Tien phau thuat: (neu co) khac 0
Benh nhan co 3 loai the bao hiem sau:
+ Gold(G): chi can thanh toan 30% chi phi
+ Silver(S): chi can thanh toan 50% chi phi
+ Citizen(C): 70% chi phi
Thiet ke ham hospitalFree
*/
#include<stdio.h>
#define G 0.3
#define S 0.5
#define C 0.7
float hospitalFree(int day, int thuoc, int pt, int tbh){
float ck, total;
if(tbh=1){
ck=G;
total=G*(day*150000+thuoc+pt);
}
else if(tbh=2){
ck=S;
total=S*(day*150000+thuoc+pt);
}
else if(tbh=3){
ck=C;
C*(day*150000+thuoc+pt);
}
printf(" ===========HOA___DON=============\n");
printf("|Phi noi tru: %20d|\n", day*150000);
printf("|Tien thuoc: %21d|\n", thuoc);
printf("|Tien phau thuat: %16d|\n", pt);
printf("|Ban chi can thanh toan %0.0f%schi phi|\n", ck*100, "%");
printf("|---------------------------------|\n");
printf("|Tong cong: %22.2lf|\n", total);
printf("|_________________________________|\n");
}
int main(){
int day, thuoc, pt;
printf("Thoi gian noi tru cua benh nhan la bao nhieu ngay? ");
scanf("%d", &day);
do{
printf("Tien thuoc cua benh nhan la bao nhieu? ");
scanf("%d", &thuoc);
if(thuoc<=0) printf("Yeu cau nhap lai tien thuoc co gia tri >0!!!\n");
}while(thuoc<=0);
do{
printf("Tien phau thuat:");
scanf("%d", &pt);
if(pt<0) printf("Yeu cau nhap lai voi gia tri >=0!!!\n");
}while(pt<0);
int tbh;
do{
printf("Loai the bao hiem cua benh nhan la gi? Gold(1)-Silver(2)-Citizen(3)\n");
scanf("%d", &tbh);
}while(tbh!=1 && tbh!=2 && tbh!=3);
hospitalFree(day, thuoc, pt, tbh);
return 0;
}
//done