#include "stdio.h"
#include "conio.h"
void main()
{
int end=0,unit,price,total;
char choice;
do
{
clrscr();
gotoxy(20,5);printf("Calculate Papa\n");
gotoxy(20,6);printf("1. Rate\n");
gotoxy(20,7);printf("2. Calculate\n");
gotoxy(20,8);printf("3. Exit");
switch (choice=getch())
{
case '1' :
clrscr();
gotoxy(20,5);printf("0 - 10 unit 2 Baht/unit\n");
gotoxy(20,6);printf("11 - 20 unit 4 Baht/unit\n");
gotoxy(20,7);printf("> 20 unit 5 Baht/unit\n");
gotoxy(20,9);printf("Press any key to continue");
getch();
end = 0;
break;
case '2' :
case2: clrscr();
gotoxy(20,5);printf("Unit : ");scanf("%d",&unit);
if (unit > 0 && unit <= 10) price = 2;
else if (unit >=11 && unit <=20) price = 4;
else if (unit > 20) price = 5;
else goto case2;
total = unit * price;
gotoxy(20,6);printf("%d Baht/unit",unit);
gotoxy(20,7);printf("Pay %3d Baht",total);
gotoxy(20,9);printf("Press any key to continue");
getch();
end = 0;
break;
case '3' :
end = 1;
break;
// default : goto again;
}
}
while (end == 0);
}