this is a programing that caloculate the sale of a weak.requirereading in the sale number and the sale of a day>but the result isn't whatwhat I want >help me find the logical error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 493245744@qq.com

    this is a programing that caloculate the sale of a weak.requirereading in the sale number and the sale of a day>but the result isn't whatwhat I want >help me find the logical error

    #include<stdio. h>
    main()
    {
    int salenumber,quan tity;
    int quantity1=0,qua ntity2=0,quanti ty3=0,quantity4 =0,quantity5=0;
    double price1,price2,p rice3,price4,pr ice5;

    printf("enter the salenumber and the quantity\n");

    while((salenumb er=getchar())!= EOF)
    {
    scanf("%d",&qua ntity);

    switch(salenumb er){
    case 1:
    quantity1+=quan tity;
    break;

    case 2:
    quantity2+=quan tity;
    break;

    case 3:
    quantity3+=quan tity;
    break;

    case 4:
    quantity4+=quan tity;
    break;

    case 5:
    quantity5+=quan tity;
    break;

    case '\n':
    case '\t':
    case ' ' :
    break;

    default:
    printf("enter a worry salenumber.");
    printf("enter a new salenumber\n");


    }
    }
    price1=2.98*qua ntity1;
    price2=4.50*qua ntity2;
    price3=9.98*qua ntity3;
    price4=4.49*qua ntity4;
    price5=6.87*qua ntity5;

    printf("price1= %f,price2=%f,pr ice3=%f,price4= %f,price5=
    %f",price1,pric e2,
    price3,price4,p rice5
    );

    system("pause") ;

    return 0;

    }
Working...