Advertisement
Guest User

hoooly heck this is long

a guest
Feb 20th, 2018
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.05 KB | None | 0 0
  1. 10. ** Student Groups
  2. At the Software University, we often organize programming courses for beginners in different towns. We usually run a registration form and after the registration finishes, we distribute the students into study groups. Groups have different sizes in each town.
  3. You are given a report holding the registrations for each town and the lab capacity (seats count) for each town. It comes in the following format:
  4. • Town name => X seats (where X is the capacity of the training lab in this town).
  5. o Student name | student email | registration date (in format day-month-year). The month name is given as 3 letters in English, e.g. “May”, “Aug” or “Nov”.
  6. o The next student come after the first, etc.
  7. • Then the next town and its students come, etc.
  8. • The input ends by a line holding “End”.
  9. The input comes in the following structure:
  10. Town1 => X seats
  11. Student1 Name | student1_email@somewhere.com | day-month-year
  12. Student2 Name | student2_email@somewhere.com | day-month-year
  13. Student3 Name | student3_email@somewhere.com | day-month-year
  14. Town2 => X seats
  15. Student1 Name | student1_email@somewhere.com | day-month-year
  16. Student2 Name | student2_email@somewhere.com | day-month-year
  17. End
  18. Your task is to create and print the study groups for each town as follows:
  19. • For each town create and print one or several study groups (depends of the number or registered students and the capacity of the lab in this town).
  20. • For each town order the students by registration date (ascending), then by name (ascending) then by email (ascending), then fill them into groups. If the students are less or equal to the lab capacity, create only one group. When the students are more than the lab capacity, distribute them in multiple groups.
  21. • Print all groups ordered by town (ascending) in the following format:
  22. o Created G groups and T towns:
  23. o Town1 => email1, email2, …
  24. o Town1 => email1, email2, …
  25. o …
  26. o Town2 => email1, email2, …
  27. o …
  28. Examples
  29. Input
  30. Plovdiv => 5 seats
  31. Ani Kirilova |ani88@abv.bg |27-May-2016
  32. Todor Nikolov | tod92@mente.org | 28-May-2016
  33. Kiril Stoyanov | kirtak@gmail.com | 27-May-2016
  34. Stefka Petrova | st96@abv.bg | 26-May-2016
  35. Ani Kirilova | ani.k@yahoo.co.uk | 27-May-2016
  36. Ivan Ivanov | ivan.i.ivanov@gmail.com| 27-May-2016
  37. Veliko Tarnovo => 3 seats
  38. Petya Stoyanova | stoyanova_p@abv.bg | 27-May-2016
  39. Stoyan Kirilov | 100yan@gmail.com | 24-May-2016
  40. Didi Miteva | miteva_d@yahoo.co.uk | 28-May-2016
  41. Kiril Nikolov | kiro@kiro.net | 25-May-2016
  42. Ivan Stefanov | ivan.stef86@gmail.com | 27-May-2016
  43. Maria Kirova | maria.k@abv.bg | 26-May-2016
  44. Varna => 2 seats
  45. Ivan Ivanov | ivan.ivanov96@gmail.com| 29-May-2016
  46. Stoyan Petrov | sto.sto.sto@gmail.com | 27-May-2016
  47. Ivan Ivanov | vankata@mail.bg | 1-Jun-2016
  48. Kiril Anev | anev_k@yahoo.co.uk | 27-May-2016
  49. Ivan Ivanov | vanyo98@abv.bg | 29-May-2016
  50. Petya Vladimirova|pete98@abv.bg | 20-May-2016
  51. Ivan Ivanov | ivan.94.ivan@gmail.com | 29-May-2016
  52. End
  53. Output
  54. Created 8 groups in 3 towns:
  55. Plovdiv => st96@abv.bg, ani.k@yahoo.co.uk, ani88@abv.bg, ivan.i.ivanov@gmail.com, kirtak@gmail.com
  56. Plovdiv => tod92@mente.org
  57. Varna => pete98@abv.bg, anev_k@yahoo.co.uk
  58. Varna => sto.sto.sto@gmail.com, ivan.94.ivan@gmail.com
  59. Varna => ivan.ivanov96@gmail.com, vanyo98@abv.bg
  60. Varna => vankata@mail.bg
  61. Veliko Tarnovo => 100yan@gmail.com, kiro@kiro.net, maria.k@abv.bg
  62. Veliko Tarnovo => ivan.stef86@gmail.com, stoyanova_p@abv.bg, miteva_d@yahoo.co.uk
  63. Comments
  64. Plovdiv (group 1 – 5/5 students)
  65. Stefka Petrova | st96@abv.bg | 26-May-2016
  66. Ani Kirilova | ani.k@yahoo.co.uk | 27-May-2016
  67. Ani Kirilova | ani88@abv.bg | 27-May-2016
  68. Ivan Ivanov | ivan.i.ivanov@gmail.com | 27-May-2016
  69. Kiril Stoyanov | kirtak@gmail.com | 27-May-2016
  70. Plovdiv (group 2 – 1/5 students)
  71. Todor Nikolov | tod92@mente.org | 28-May-2016
  72. Varna (group 1 – 2/2 students)
  73. Petya Vladimirova | pete98@abv.bg | 20-May-2016
  74. Kiril Anev | anev_k@yahoo.co.uk | 27-May-2016
  75. Varna (group 2 – 2/2 students)
  76. Stoyan Petrov | sto.sto.sto@gmail.com | 27-May-2016
  77. Ivan Ivanov | ivan.94.ivan@gmail.com | 29-May-2016
  78. Varna (group 3 – 2/2 students)
  79. Ivan Ivanov | ivan.ivanov96@gmail.com | 29-May-2016
  80. Ivan Ivanov | vanyo98@abv.bg | 29-May-2016
  81. Varna (group 4 – 1/2 students)
  82. Ivan Ivanov | vankata@mail.bg | 1-Jun-2016
  83. Veliko Tarnovo (group 1 – 3/3 students)
  84. Stoyan Kirilov | 100yan@gmail.com | 24-May-2016
  85. Kiril Nikolov | kiro@kiro.net | 25-May-2016
  86. Maria Kirova | maria.k@abv.bg | 26-May-2016
  87. Veliko Tarnovo (group 2 – 3/3 students)
  88. Ivan Stefanov | ivan.stef86@gmail.com | 27-May-2016
  89. Petya Stoyanova | stoyanova_p@abv.bg | 27-May-2016
  90. Didi Miteva | miteva_d@yahoo.co.uk | 28-May-2016
  91. Hints
  92. First, create the classes to hold the students, towns and groups.
  93. Creating Classes Student, Town and Group
  94. The class Student will hold the information about a student: name, email and date of registration.
  95.  
  96. The class Town will hold the information about a town holding a list of registered students.
  97.  
  98. The class Groups will hold the information about a group holding a subset of the students for certain town.
  99.  
  100. Read the Input
  101. The next step is to read and parse the input to list of towns, each holding a list of students. Write a method to read the input from the console:
  102.  
  103. In a loop, read a text line inputLine from the console, until “End” is reached.
  104. For each input line check whether the input line contains “=>”.
  105. • If yes  inputLine holds a town, e.g. “Plovdiv => 5 seats”.
  106. o Create a new Town object.
  107. o Parse the town name and seats count from the input line and put them in the town.
  108. o Assign an empty student list for the new town:
  109. town.Students = new List<Student>().
  110. o Add the new town to the list of towns.
  111. • If no  inputLine holds a student, e.g. “Ani Kirilova | ani.k@yahoo.co.uk | 27-May-2016”.
  112. o Create a new Student object.
  113. o Parse the student name, email and date from the input line and put them in the student.
  114. o Append the new student to the list of students for the last town in the towns list.
  115. Distribute the Students into Groups
  116. Now, solve the essential part of the problem: for each town, create one or several groups and distribute the students between them.
  117. Start from an empty method that takes as input a list of towns and produces as output a list of groups:
  118.  
  119. How to distribute the students?
  120. In a loop go through the towns, sorted by name.
  121. • For each town order the students by registration date, name and email.
  122. • For each town put the first Town.SeatsCount students in the first group, the next Town.SeatsCount students in the second group, etc.
  123. You may use code like this or write it yourself:
  124.  
  125. Print the Groups
  126. Once the students are distributed into groups, printing the output is the easiest part of this problem.
  127. • Print the total count of groups and total count of towns (distinct town names).
  128. • Loop through the groups, sorted by town name.
  129. • For each group print its name and the emails of its students, joined by “, ”.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement