Advertisement
desislava_topuzakova

1. SoftUni Reception

Jun 14th, 2023
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package ExamPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FirstTask {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. //1. входни данни
  10. int firstEmployeeStudents = Integer.parseInt(scanner.nextLine()); //брой студенти, които обслужва първия служител на час
  11. int secondEmployeeStudents = Integer.parseInt(scanner.nextLine()); //брой студенти, които обслужва втория служител на час
  12. int thirdEmployeeStudents = Integer.parseInt(scanner.nextLine()); //брой студенти, които обслужва третия служител на час
  13. int studentsCount = Integer.parseInt(scanner.nextLine()); //общ брой студенти, които трябва да бъдат обслужени
  14.  
  15. int studentsPerHour = firstEmployeeStudents + secondEmployeeStudents + thirdEmployeeStudents; //брой студенти, обслужени за 1 час
  16. int totalHours = 0; //брой часове, нужни за обслужването на всички студенти
  17.  
  18. //повтаряме: обслужваме максималния брой студенти за служител
  19. //спираме: студенти <= 0
  20. //продължаваме: студенти > 0
  21.  
  22. while (studentsCount > 0) {
  23. //обслужване
  24. totalHours++;
  25. if (totalHours % 4 == 0) {
  26. continue;
  27. }
  28. //общ брой студенти, обслужени за 1 час
  29. studentsCount -= studentsPerHour;
  30. }
  31.  
  32. System.out.printf("Time needed: %dh.", totalHours);
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement