#include <stdio.h>
int main(void) {
float com,value,p,r,s;
printf("Enter the number of shares: ");
scanf("%f", &s);
printf("Enter the price per share: ");
scanf("%f", &p);
value=s * p;
if (value<2500.00f)
com=30.00f+ .017fvalue;
else if (value<6250.00f)
com=56.00f+ .0066fvalue;
else if (value<20000.00f)
com=76.00f+ .0034fvalue;
else if (value<50000.00f)
com=100.00f+ .0022fvalue;
else if (value<500000.00f)
com=155.00f+ .0011fvalue;
else
com=255.00f+ .0009fvalue;
if (r>=2000)
r=33.00f+0.02f*s;
else if (r<2000)
r=33.00f+0.03f*s;
printf("Original broker's commission: $%.2f\n", com);
printf("Rival broker's commission: $%.2f", r);
return 0;
}
//Input Data:
//2000
//2.5
//========================================
//Except:
//Enter the number of shares: Enter price per share: Original broker's commission: $89.00
//Rival broker's commission: $73.00
//========================================
//Actual:
//Enter the number of shares: Enter price per share: Original broker's commission: $89.00
//Rival broker's commission: $93.00
第24列
if (r>=2000)
改成
if (s>=2000)
另外
如果你還想繼續問程設問題的話
貼程式碼時請在程式碼的前後加上三個單引號(鍵盤上最左上那個), 效果像這樣
if (value<2500.00f)
com=30.00f+ .017*fvalue;
否則會變這樣
if (value<2500.00f)
com=30.00f+ .017fvalue;
會浪費時間