-
Notifications
You must be signed in to change notification settings - Fork 0
/
StudentGrading_v2.cs
102 lines (73 loc) · 2.98 KB
/
StudentGrading_v2.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
/*
This code a Student Grading application that automates
the calculation of grades for each student in a class
then prints the results to the console window.
*/
// initialize variables - graded assignments
int currentAssignments = 5;
int[] sophiaScores = new int[] { 90, 86, 87, 98, 100 };
int[] andrewScores = new int[] { 92, 89, 81, 96, 90 };
int[] emmaScores = new int[] { 90, 85, 87, 98, 68 };
int[] loganScores = new int[] { 90, 95, 87, 88, 96 };
// Student names
string[] studentNames = new string[] { "Sophia", "Andrew", "Emma", "Logan" };
int[] studentScores = new int[10];
string currentStudentLetterGrade = "";
// Display the Report Header
Console.WriteLine("Student\t\tGrade\n");
foreach (string name in studentNames)
{
string currentStudent = name;
if (currentStudent == "Sophia")
// assign Sophia's scores to the studentScores array
studentScores = sophiaScores;
else if (currentStudent == "Andrew")
// assign Andrew's scores to the studentScores array
studentScores = andrewScores;
else if (currentStudent == "Emma")
// assign Emma's scores to the studentScores array
studentScores = emmaScores;
else if (currentStudent == "Logan")
// assign Logan's scores to the studentScores array
studentScores = loganScores;
// initialize/reset the sum of scored assignments
int sumAssignmentScores = 0;
// initialize/reset the calculated average of exam + extra credit scores
decimal currentStudentGrade = 0;
foreach (int score in studentScores)
{
// add the exam score to the sum
sumAssignmentScores += score;
}
currentStudentGrade = (decimal)(sumAssignmentScores) / currentAssignments;
if (currentStudentGrade >= 97)
currentStudentLetterGrade = "A+";
else if (currentStudentGrade >= 93)
currentStudentLetterGrade = "A";
else if (currentStudentGrade >= 90)
currentStudentLetterGrade = "A-";
else if (currentStudentGrade >= 87)
currentStudentLetterGrade = "B+";
else if (currentStudentGrade >= 83)
currentStudentLetterGrade = "B";
else if (currentStudentGrade >= 80)
currentStudentLetterGrade = "B-";
else if (currentStudentGrade >= 77)
currentStudentLetterGrade = "C+";
else if (currentStudentGrade >= 73)
currentStudentLetterGrade = "C";
else if (currentStudentGrade >= 70)
currentStudentLetterGrade = "C-";
else if (currentStudentGrade >= 67)
currentStudentLetterGrade = "D+";
else if (currentStudentGrade >= 63)
currentStudentLetterGrade = "D";
else if (currentStudentGrade >= 60)
currentStudentLetterGrade = "D-";
else
currentStudentLetterGrade = "F";
Console.WriteLine($"{name}\t\t{currentStudentGrade}\t?");
}
Console.WriteLine("Press the Enter key to continue");
Console.ReadLine();