#include "stdafx.h"
int main()
{
char chose;
int count=0,i = 0,sum=0;
printf("________________________________________________________________________\n");
printf("|________________________________ Manu ________________________________|\n");
printf("|[1] Rice ---------------------- 15 Bath------------------Enter A or a-|\n");
printf("|[2] Fried rice with Shrimp ---- 45 Bath------------------Enter B or b-|\n");
printf("|[3] Stir-fried pork and basil-- 45 Bath------------------Enter C or c-|\n");
printf("\n");
while (i <=1)
{
count += 1;
printf("\n\nEnter your Manu : ");
chose = getchar();
if (chose == 'A' || chose == 'a')
{
printf("Your select Rice 15 Bath\n");
sum += 15;
}
else if (chose == 'B' || chose == 'b')
{
printf("Your select Fried rice with Shrimp 45 Bath\n");
sum += 45;
}
else if (chose == 'C' || chose == 'c')
{
printf("Your select Rice topped with stir-fried pork and basil 45 Bath\n");
sum += 45;
}
else if (chose == 'L' || chose == 'l')
{
printf("Your select Check bill\n");
printf("You have a manu %d items\n", count - 1);
printf("Food you price is : %d\n", sum);
i += 1;
break;
}
}
printf("Thank you");
getchar();
getchar();
return 0;
}
ช่วยทีครับ รัน while loop แล้ว มันรันเบิ้ลทุกรอบเลยครับ
int main()
{
char chose;
int count=0,i = 0,sum=0;
printf("________________________________________________________________________\n");
printf("|________________________________ Manu ________________________________|\n");
printf("|[1] Rice ---------------------- 15 Bath------------------Enter A or a-|\n");
printf("|[2] Fried rice with Shrimp ---- 45 Bath------------------Enter B or b-|\n");
printf("|[3] Stir-fried pork and basil-- 45 Bath------------------Enter C or c-|\n");
printf("\n");
while (i <=1)
{
count += 1;
printf("\n\nEnter your Manu : ");
chose = getchar();
if (chose == 'A' || chose == 'a')
{
printf("Your select Rice 15 Bath\n");
sum += 15;
}
else if (chose == 'B' || chose == 'b')
{
printf("Your select Fried rice with Shrimp 45 Bath\n");
sum += 45;
}
else if (chose == 'C' || chose == 'c')
{
printf("Your select Rice topped with stir-fried pork and basil 45 Bath\n");
sum += 45;
}
else if (chose == 'L' || chose == 'l')
{
printf("Your select Check bill\n");
printf("You have a manu %d items\n", count - 1);
printf("Food you price is : %d\n", sum);
i += 1;
break;
}
}
printf("Thank you");
getchar();
getchar();
return 0;
}