/*
- 4.2.c
- Created on: 2018年10月25日
-
Author: yangchenglong
/
#include<stdio.h>
int main(void)
{
int number;
float commission_one,commission_two,share,value;
do
{
printf(“Enter number of shares:”);
setvbuf(stdout,NULL,_IONBF,0);
scanf("%d",&number);
if(number == 0)
{
break;
}
printf(“Enter price per share:”);
scanf("%f",&share);
if (value < 2500.00f) //第一个经纪人求佣金
{
commission_one = 30.00f + 0.17fvalue;
}
else if (value < 6250.00f)
{
commission_one = 56.00f + 0.066fvalue;
}
else if (value < 20000.00f)
{
commission_one = 76.00f + 0.034fvalue;
}
else if (value < 50000.00f)
{
commission_one = 100.00f + 0.022fvalue;
}
else if (value < 500000.00f)
{
commission_one = 155.00f + 0.011fvalue;
}
else
{
commission_one = 255.00f + 0.009value;
}
if (commission_one < 39.00f)
{
commission_one = 39.00f;
}
printf(“The first broker’s commission:%.2f\n”,commission_one);
if (number <= 2000) //第二个经纪人求佣金
{
commission_two = 33.00f + 0.03fvalue;
}
else
{
commission_two = 33.00f + 0.02f*value;
}
printf(“The second broker’s commission:%.2f\n”,commission_two);
if (commission_one < commission_two) //比较两经纪人佣金大小
{
printf(“The first broker is the right one\n”);
}
else if (commission_one > commission_two)
{
printf(“The second broker is the right one\n”);
}
else
{
printf(“They all right\n”);
}
}while (number != 0);
return 0;
}