我正在開發一個程序。這是我想要實現的; 該計劃應該提供一個工資率選擇菜單。使用開關選擇工資率。運行的開始應該如下所示: C代碼,我錯過了這個控制語句程序?
如果選擇了選項1到4,程序應該請求工作的小時數。程序應該循環使用,直到輸入5。如果輸入了選擇1至5之外的其他內容,程序應提醒用戶適當的選擇,然後回收。使用#defined常量獲取各種收益率和稅率。
這是我到目前爲止的代碼,我錯過了什麼?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int choice, hour;
float taxe, total;
printf("****************************************************************\n");
printf("\nEnter the number corresponding to the desired pay rate or action");
printf("\n1)$8.75/hr");
printf("\n2)$9.33/hr");
printf("\n3)$10.00/hr");
printf("\n4)$11.20hr");
printf("\n5)Quit");
printf("**********************************************************\n");
scanf("%d", &choice);
printf("Please enter number of hours: ");
scanf("%d", &hour);
switch(choice){
case 1:
total = 8.75* hour;
break;
case 2:
total = 9.33*hour;
break;
case 3:
total = 10.00*hour;
break;
case 4:
total = 11.20*hour;
break;
case 5:
break;
return 0;
}
}
這聽起來像功課給我,是嗎? – anderas
@KlasLindbäck謝謝你,這是有道理的。我是否需要使用「while」循環,還是需要成爲「do while」循環? – user3247128