|
#include <stdio.h>
void main()
{char goods='a';
int money=0;
int balance=0;
char choise='N';
while(1)
{printf("please enter goods that you want to buy\n");
scanf(" %c",&goods);
if((goods!='a')&&(goods!='b')&&(goods!='c')&&(goods!='d')&&(goods!='e')) {printf("please choose your goods again\n");continue;};
printf("please drop your money\n");
scanf(" %d",&money);
if(money==1)
{if(goods=='a') balance=0;
else balance=-1;
}
else
if(money==10)
{switch(goods)
{case 'a':balance=9;break;
case 'b':balance=7;break;
case 'c':balance=7;break;
case 'd':balance=7;break;
case 'e':balance=3;break;
default:balance=-1;
}
}
else
{printf("your money isn't available\n");continue;};
if(balance==-1) {printf("your money isnot enough\n");continue;};
printf("please choose key\n");
scanf(" %c",&choise);
if(choise=='Y') printf("your balance is %d\n",balance);
else printf("take back your money\n");
}
} |
|