欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C语言计算佣金

程序员文章站 2022-11-18 13:56:45
#include int main(void) { int shares; float price,value,commission,riv...
#include<stdio.h>
int main(void)
{
    int shares;
    float price,value,commission,rival_commission;


    printf("enter number of shares:");
    setvbuf(stdout,null,_ionbf,0);
    scanf("%d",&shares);
    printf("enter price per share:");
    scanf("%f",&price);


    value =shares*price;


    if(value<2500.00f)
        commission=30.00f+.007f*value;
    else if (value<6250.00f)
        commission=56.00f+.0066f*value;
    else if (value <20000.00f)
        commission=76.00f+.0024f*value;
    else if(value<50000.00f)
        commission=100.00f+.0022f*value;
    else if(value<50000.00f)
        commission=155.00f+.0011f*value;
    else
        commission=255.00f+.0009f*value;


    if(commission<39.00f)
        commission=39.00f;


    rival_commission=33.00f+(shares<2000?.03f:.02f);




    printf("the first broker's commission :$%.2f\n",commission);
    printf("the second broker's commission:$%.2f\n",rival_commission);


    if(commission<rival_commission)
    {
        printf("the first broker is the right one.\n");
    }
    else{
        printf("the second broker irus the right one.\n");
    }
    return 0;
}