Didart

SoftUni Reception

Oct 19th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SoftUniReception {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int studentsAnswerPerHour = 0;
  8.  
  9.         for (int i = 1; i <= 3; i++) {
  10.             studentsAnswerPerHour += Integer.parseInt(scanner.nextLine());
  11.         }
  12.  
  13.         int studentsCount = Integer.parseInt(scanner.nextLine());
  14.  
  15.         int hours = 0;
  16.  
  17.         while (studentsCount > 0) {
  18.             studentsCount -= studentsAnswerPerHour;
  19.             hours++;
  20.             if (hours % 4 == 0) {
  21.                 hours++;
  22.             }
  23.         }
  24.         System.out.printf("Time needed: %dh.", hours);
  25.     }
  26. }
  27.  
  28.  
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment