用 Sub Procedure 批次填入 Tax Amount、Bonus Rate、Bonus Amount、Net Pay 與 Performance Level,並比較 If…Then…ElseIf 與 Select Case。
管理者不只需要單一計算值,而是要一次完成整張員工表。來源因此要求 ApplyEmployeeCalculations 呼叫 Function 並填入多個輸出欄位。
| Name | Tax | Bonus | Net Pay | Performance Level |
|---|---|---|---|---|
| Raja | 6240 | 18000 | 63760 | Excellent |
| Suman | 5040 | 0 | 36960 | Good |
| Kuldeep | 7320 | 7000 | 60680 | Needs Review |
| Beena | 9000 | 37500 | 103500 | Excellent |
| Seema | 8160 | 0 | 59840 | Good |
| Deepak | 6600 | 6000 | 54400 | Needs Review |
| Neena | 4680 | 0 | 34320 | Good |
| Pankaj | 5640 | 16000 | 57360 | Good |
| Andre | 8640 | 5500 | 68860 | Excellent |
| Sujay | 6000 | 5250 | 49250 | Needs Review |
來源指定:建立 GetPerformanceLevel(attendance, rating, training),回傳 Excellent/Good/Watch/Needs Review;再由 ApplyEmployeeCalculations 將所有結果寫回每列。Task 4 指定可用 If…Then…ElseIf 或 Select Case。
來源完成案例如表。Net Pay 例如 Raja = 52,000 − 6,240 + 18,000 = 63,760;Beena = 75,000 − 9,000 + 37,500 = 103,500。
Function 適合回答「一筆輸入對應一個結果」;Sub 則負責流程與寫入。績效分級規則在來源完成表有明確輸出,但來源片段沒有提供每一級的完整條件門檻,因此不額外自行補寫門檻。
請根據來源完成案例設計 GetPerformanceLevel 與 ApplyEmployeeCalculations,並說明 Function 回傳值與 Sub 批次寫入的差異;若來源未提供完整分級門檻,請明確標示不可自行推定。
**問題:**若只想取得單一員工的 Performance Level,應優先用 Function 還是 Sub?