Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. g System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp50
  9. {
  10. public class Student
  11. {
  12. public string name;
  13. public int[] mark;
  14. public double aver;
  15. public Student(string name, int[] mark)
  16. {
  17. this.name = name;
  18. this.mark = mark;
  19. aver = 0;
  20. for (int i = 0; i < 5; i++)
  21. {
  22. aver += mark[i];
  23. }
  24. aver /= 5;
  25. }
  26. }
  27. public class GraduateStudent : Student
  28. {
  29. public int scolarship;
  30. public GraduateStudent(string name, int[] mark) : base(name, mark)
  31. {
  32. this.name = name;
  33. this.mark = mark;
  34. aver = 0;
  35. for (int i = 0; i < 5; i++)
  36. {
  37. aver += mark[i];
  38. }
  39. aver /= 5;
  40. if ((aver >= 4) && (aver < 5))
  41. {
  42. scolarship = 1500;
  43. }
  44. else
  45. {
  46. if (aver == 5)
  47. {
  48. scolarship = 2250;
  49. }
  50. else
  51. {
  52. scolarship = 0;
  53. }
  54. }
  55. }
  56. }
  57. class Program
  58. {
  59. static void Main(string[] args)
  60. {
  61. GraduateStudent[] st = new GraduateStudent[5];
  62. StreamReader sr = new StreamReader("D:\\Универская фигота\\Экзамен прога\\Студенты.txt", Encoding.GetEncoding(1251));
  63. string line;
  64. int i = 0;
  65. int[] m = new int[5];
  66. while ((line = sr.ReadLine()) != null)
  67. {
  68. string[] studentData = line.Split(' ');
  69. st[i].name = studentData[0];
  70.  
  71. for (int j = 0; j < 5; j++)
  72. {
  73. m[j]= int.Parse(studentData[j + 1]);
  74. if (m[j] == 2)
  75. {
  76. i = i - 1;
  77. break;
  78. }
  79. else
  80. {
  81. st[i].mark[j] = int.Parse(studentData[j + 1]);
  82. }
  83. }
  84. i++;
  85. }
  86. for (int j = 0; j < 5; j++)
  87. {
  88. Console.Write(st[j].name + " " + st[j].scolarship);
  89. }
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement