Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Threading.Tasks;
- namespace ConsoleApp50
- {
- public class Student
- {
- public string name;
- public int[] mark;
- public double aver;
- public Student(string name, int[] mark)
- {
- this.name = name;
- this.mark = mark;
- aver = 0;
- for (int i = 0; i < 5; i++)
- {
- aver += mark[i];
- }
- aver /= 5;
- }
- }
- public class GraduateStudent : Student
- {
- public int scolarship;
- public GraduateStudent(string name, int[] mark) : base(name, mark)
- {
- this.name = name;
- this.mark = mark;
- aver = 0;
- for (int i = 0; i < 5; i++)
- {
- aver += mark[i];
- }
- aver /= 5;
- if ((aver >= 4) && (aver < 5))
- {
- scolarship = 1500;
- }
- else
- {
- if (aver == 5)
- {
- scolarship = 2250;
- }
- else
- {
- scolarship = 0;
- }
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- GraduateStudent[] st = new GraduateStudent[5];
- StreamReader sr = new StreamReader("D:\\Универская фигота\\Экзамен прога\\Студенты.txt", Encoding.GetEncoding(1251));
- string line;
- int i = 0;
- int[] m = new int[5];
- while ((line = sr.ReadLine()) != null)
- {
- string[] studentData = line.Split(' ');
- st[i].name = studentData[0];
- for (int j = 0; j < 5; j++)
- {
- m[j]= int.Parse(studentData[j + 1]);
- if (m[j] == 2)
- {
- i = i - 1;
- break;
- }
- else
- {
- st[i].mark[j] = int.Parse(studentData[j + 1]);
- }
- }
- i++;
- }
- for (int j = 0; j < 5; j++)
- {
- Console.Write(st[j].name + " " + st[j].scolarship);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement