-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.cs
65 lines (55 loc) · 2.31 KB
/
app.cs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
internal class Program
{
private static void Main(string[] args)
{
//student name
string studentName = "Mahmood Ademoye";
//course titles
string course1Name = "Fluid Mechanics";
string course2Name = "Material Science";
string course3Name = "Control Systems";
string course4Name = "Mechanical Vibration";
string course5Name = "Machine Design";
//course credits
int course1Credit = 5;
int course2Credit = 4;
int course3Credit = 4;
int course4Credit = 5;
int course5Credit = 5;
//grades points equivalent
int gradeA = 5;
int gradeB = 4;
//course grades
int course1Grade = gradeA;
int course2Grade = gradeB;
int course3Grade = gradeB;
int course4Grade = gradeA;
int course5Grade = gradeA;
//Total credit hours
int totalCreditHours = 0;
totalCreditHours = course1Credit + course2Credit + course3Credit + course4Credit + course5Credit;
//Total Grade points
int totalGradePoints = 0;
totalGradePoints += course1Credit * course1Grade;
totalGradePoints += course2Credit * course2Grade;
totalGradePoints += course3Credit * course3Grade;
totalGradePoints += course4Credit * course4Grade;
totalGradePoints += course5Credit * course5Grade;
//GPA
decimal gradePointAverage = (decimal) totalGradePoints/totalCreditHours;
int leadingDigit = (int) gradePointAverage;
int firstDigit = (int) (gradePointAverage * 10) % 10;
int secondDigit = (int) (gradePointAverage * 100) % 10;
//OUTPUT
Console.WriteLine($"Student: {studentName}\n");
//Headers
Console.WriteLine($"Course\t\t\t\tGrade\tCredit Hours");
//Results
Console.WriteLine($"{course1Name}\t\t\t{course1Grade}\t\t{course1Credit}");
Console.WriteLine($"{course2Name}\t\t{course2Grade}\t\t{course2Credit}");
Console.WriteLine($"{course3Name}\t\t\t{course3Grade}\t\t{course3Credit}");
Console.WriteLine($"{course4Name}\t{course4Grade}\t\t{course4Credit}");
Console.WriteLine($"{course5Name}\t\t\t{course5Grade}\t\t{course5Credit}");
Console.WriteLine($"\nFinal GPA:\t\t\t{leadingDigit}.{firstDigit}{secondDigit}");
}
}