-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDateTime.cs
More file actions
96 lines (83 loc) · 2.45 KB
/
DateTime.cs
File metadata and controls
96 lines (83 loc) · 2.45 KB
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
using System;
using System.Linq;
class Person
{
protected string firstName;
protected string lastName;
protected int id;
public Person() { }
public Person(string firstName, string lastName, int identification)
{
this.firstName = firstName;
this.lastName = lastName;
this.id = identification;
}
public void printPerson()
{
Console.WriteLine("Name: " + lastName + ", " + firstName + "\nID: " + id);
}
}
class Student : Person
{
private int[] testScores;
/* Class Constructor
*
* Parameters:
* firstName - A string denoting the Person's first name.
* lastName - A string denoting the Person's last name.
* id - An integer denoting the Person's ID number.
* scores - An array of integers denoting the Person's test scores.
*/
// Write your constructor here
public Student(string fn, string ln, int id, int[] sc)
{
new Person(fn, ln, id);
testScores = sc;
}
/*
* Method Name: Calculate
* Return: A character denoting the grade.
*/
// Write your method here
public char Calculate()
{
char[] grade = new char[] { 'O', 'E', 'A', 'P', 'D', 'T' };
int sum = 0;
foreach (int i in testScores)
{
sum += i;
}
int a = sum / testScores.Length;
if (a <= 100 && a >= 90)
return grade[0];
else if (a < 90 && a >= 80)
return grade[1];
else if (a < 80 && a >= 70)
return grade[2];
else if (a >= 55 && a < 70)
return grade[3];
else if (a >= 40 && a < 55)
return grade[4];
else
return grade[5];
}
}
class Solution {
static void Main()
{
string[] inputs = Console.ReadLine().Split();
string firstName = inputs[0];
string lastName = inputs[1];
int id = Convert.ToInt32(inputs[2]);
int numScores = Convert.ToInt32(Console.ReadLine());
inputs = Console.ReadLine().Split();
int[] scores = new int[numScores];
for (int i = 0; i < numScores; i++)
{
scores[i] = Convert.ToInt32(inputs[i]);
}
Student s = new Student(firstName, lastName, id, scores);
s.printPerson();
Console.WriteLine("Grade: " + s.Calculate() + "\n");
}
}