ChameL1oN

ЯПЛаба3

Mar 23rd, 2015
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ForZakaz2
  8. {
  9.  
  10.  
  11. //Построить описание класса, содержащего информацию о факультете.
  12. //Описание должно содержать не менее 4 полей различных типов и два метода.
  13. //Составить программу, демонстрирующую работу с этим классом, содержащую условный оператор.
  14.  
  15. public class Fakultet
  16. {
  17. public string Name { get; set; }
  18. public int CountStud { get; set; }
  19. public int CountPrep { get; set; }
  20. public string Dekan { get; set; }
  21.  
  22. public Fakultet()
  23. {
  24. Console.WriteLine("Название факультета?");
  25. this.Name = Console.ReadLine();
  26. Console.WriteLine("Кол-во студентов?");
  27. this.CountStud = int.Parse(Console.ReadLine());
  28. Console.WriteLine("Кол-во преподавателей?");
  29. this.CountPrep = int.Parse(Console.ReadLine());
  30. Console.WriteLine("Фамилия декана?");
  31. this.Dekan = Console.ReadLine();
  32. Console.WriteLine(" ");
  33. }
  34.  
  35. public void Print()
  36. {
  37. Console.WriteLine(this.Name + " Count Students : " + this.CountStud + " Count Prepods : " + this.CountPrep + " Name of Dekan : " + this.Dekan);
  38. }
  39.  
  40. }
  41.  
  42.  
  43. class Program
  44. {
  45. static void Main(string[] args)
  46. {
  47. int n;
  48. Console.WriteLine("Введите кол-во факультетов");
  49. n = int.Parse(Console.ReadLine());
  50. Fakultet[] massiv = new Fakultet[n];
  51. for (int i = 0; i < n; i++)
  52. {
  53. massiv[i] = new Fakultet();
  54. }
  55. Console.WriteLine(" ");
  56. Console.WriteLine("Факультеты : ");
  57. for (int i = 0; i < n; i++)
  58. {
  59. massiv[i].Print();
  60. }
  61. Console.WriteLine(" ");
  62. Console.WriteLine(" ");
  63. Console.WriteLine("Факультеты с кол-вом студентов больше 300 : ");
  64. Console.WriteLine(" ");
  65. for (int i = 0; i < n; i++)
  66. {
  67. if (massiv[i].CountStud > 300)
  68. {
  69. massiv[i].Print();
  70. }
  71. }
  72. }
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment