我的是学生作业,一共有三个小问题。问题出在了第三个问题。第一个和第二问题
都是按着顺序执行,执行完第二个问题以后会直接执行第三个问题的最后一个
else,然后直接结束了。但是单独把问题三拿出来运行是没有问题的。请各位大神帮我看一下是那里写错了呢?谢谢各位大佬。
#include<stdio.h>
int main()
{
char one_sport;
int two_people;
int two_priceA;
int two_priceB;
int two_priceC;
char three_sort;
int three_quantity;
int three_aq;
int three_bq;
int three_cq;
double priceA;
double priceB;
double priceC;
//problem 1
printf("Problem 1\n");
printf("Enter w for walk and s for swim\n");
scanf("%c",&one_sport);
if(one_sport == 'w')
{
printf("You need to walk 15.2 hours to burn off a pound\n");
}
else
{
printf("You need to swim 8.75 hours to burn off a pound\n");
}
//problem 2
printf("problem 2\n");
printf("How many in your group\n");
scanf("%d",&two_people);
two_priceA = two_people * 15;
two_priceB = two_people * 12;
two_priceC = two_people * 10;
if(two_people >=1&&two_people<=8 )
{
printf("Total cost for your group is %d\n",two_priceA);
}
else if(two_people >=9&&two_people<=15)
{
printf("Total cost for your group is %d\n",two_priceB);
}
else
{
printf("Total cost for your group is %d\n",two_priceC);
}
//problem 3
printf("problem 3\n");
printf("Enter A if you want to purchase a shirt,a B if you want to purchase a hat,\nand C if you want to enter a poster.\n");
scanf("%c",&three_sort);
switch(three_sort)
{
case 'A':printf("Enter your quantity\n"); break;
case 'B':printf("Enter your quantity\n"); break;
case 'C':printf("Enter your quantity\n"); break;
}
if(three_sort =='A')
{
scanf("%d",&three_aq);
priceA = three_aq * 10;
printf("You owe $%.2lf\n",priceA);
}
else if(three_sort =='B')
{
scanf("%d",&three_bq);
priceB = three_bq * 20;
printf("You owe $%.2lf\n",priceB);
}
else if(three_sort =='C')
{
scanf("%d",&three_cq);
priceC = three_cq * 30;
printf("You owe $%.2lf\n",priceC);
}
else
{
printf("Your owe $0");
}
}