Microsoft 2023 年所提供的 C# codecamp 基礎課程,總共有 38 個單元,完成後就可以獲得 Certification ,今天要來跟大家分享的是第五單元章節的內容。
本節內容
建立變數以及做基本的數學運算,最後還有型別轉換等功能的總體練習,題目是幫每個學生的作業分數做一個加總的總和。
下面是該練習的解題答案:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| int currentAssignments = 5;
int sophia1 = 93; int sophia2 = 87; int sophia3 = 98; int sophia4 = 95; int sophia5 = 100;
int nicolas1 = 80; int nicolas2 = 83; int nicolas3 = 82; int nicolas4 = 88; int nicolas5 = 85;
int zahirah1 = 84; int zahirah2 = 96; int zahirah3 = 73; int zahirah4 = 85; int zahirah5 = 79;
int jeong1 = 90; int jeong2 = 92; int jeong3 = 98; int jeong4 = 100; int jeong5 = 97;
int sophiaSum = sophia1 + sophia2 + sophia3 + sophia4 + sophia5; int nicolasSum = nicolas1 + nicolas2 + nicolas3 + nicolas4 + nicolas5; int zahirahSum = zahirah1 + zahirah2 + zahirah3 + zahirah4 + zahirah5; int jeongSum = jeong1 + jeong2 + jeong3 + jeong4 + jeong5;
decimal sophiaScore = (decimal) sophiaSum / currentAssignments; decimal nicolasScore = (decimal) nicolasSum / currentAssignments; decimal zahirahScore = (decimal) zahirahSum / currentAssignments; decimal jeongScore = (decimal) jeongSum / currentAssignments;
Console.WriteLine("Student\t\tGrade\n"); Console.WriteLine("Sophia:\t\t" + sophiaScore + "\tA"); Console.WriteLine("Nicolas:\t" + nicolasScore + "\tB"); Console.WriteLine("Zahirah:\t" + zahirahScore + "\tB"); Console.WriteLine("Jeong:\t\t" + jeongScore + "\tA");
|
重點整理
這篇意外的沒什麼重點,大概就是前面四個章節大統整後的練習這樣。
那我們下次見ʘ‿ʘ
參考資料