Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM
- class Program
- {
- static void Main(string[] args)
- {
- Person[] array = new Person[100];
- int i = 0;
- int highest = 0;
- int secondHighest = 0;
- int thirdHighest = 0;
- try
- {
- FileStream fs = new FileStream(@"C:\Users\User_2\Desktop\metalgearsolid.txt", FileMode.Open);
- StreamReader readin = new StreamReader(fs);
- while (!readin.EndOfStream)
- {
- string init = "";
- init = readin.ReadLine();
- string[] info = init.Split(',');
- int grade = int.Parse(info[3]);
- array[i] = new Person(info[0], info[1], info[2], grade);
- i++;
- }
- readin.Close();
- fs.Close();
- }
- catch (Exception e) { }
- for (int j = 0; j < i; j++)
- {
- if (array[j].Grade > array[highest].Grade)
- {
- highest = j;
- }
- }
- for (int x = 0; x < i; x++)
- {
- if (array[x].Grade > array[secondHighest].Grade && array[x].Grade < array[highest].Grade)
- {
- secondHighest = x;
- }
- }
- for (int v = 0; v < i; v++)
- {
- if (array[v].Grade > array[secondHighest].Grade && array[v].Grade < array[highest].Grade && array[v].Grade < array[secondHighest].Grade)
- {
- thirdHighest = v;
- }
- }
- Console.WriteLine(array[highest].Name);
- Console.WriteLine(array[secondHighest].Name);
- Console.WriteLine(array[thirdHighest].Name);
- Console.ReadKey();
- }
- }
- PERSON
- class Person
- {
- private string name;
- private string number;
- public string course;
- public int grade;
- public Person(string name, string number, string course, int grade)
- {
- this.name = name;
- this.number = number;
- this.course = course;
- this.grade = grade;
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- name = value;
- }
- }
- public string Number
- {
- get
- {
- return number;
- }
- set
- {
- number = value;
- }
- }
- public string Course
- {
- get
- {
- return course;
- }
- set
- {
- course = value;
- }
- }
- public int Grade
- {
- get
- {
- return grade;
- }
- set
- {
- grade = value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement