#include<stdio.h>
int main(void)
{
    int choice,i;
    double price;

    for(i=1;i<=5;i++){
        printf("[1] Select apples \n");
        printf("[2] Select pears \n");
        printf("[3] Select oranges \n");
        printf("[4] Select grapes \n");
        printf("[0] exit \n");

        printf("Enter choice:");
        scanf_s("%d",&choice);

        if(choice==0)
            break;

        switch(choice){/*利用switch,break显示各项*/
        case 1:price=3.00;
            break;
        case 2:price=2.50;
            break;
        case 3:price=4.10;
            break;
        case 4:price=10.20;
            break;
        }

        printf("price=%.2f\n",price);
    }
    printf("Thanks \n");

    return 0;
}

 

作业3(6)查询水果的单价。有 4 种水果,苹果(apples)、梨(pears)、桔子(oranges)和葡萄(grapes),

相关文章:

  • 2021-12-12
  • 2022-12-23
  • 2021-12-22
  • 2021-12-12
  • 2022-01-18
  • 2021-08-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案