Advertisement
ralitsa_d

Hospital

Feb 23rd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hospital {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. Integer period = Integer.parseInt(scan.nextLine());
  8.  
  9. Integer hostedPatients = 0;
  10. Integer nonhostedPatients = 0;
  11. Integer doctors = 7;
  12.  
  13. for (int i = 1; i <= period; i++) {
  14.  
  15. if (i % 3 == 0 && hostedPatients < nonhostedPatients){
  16. doctors++;
  17. }
  18.  
  19. Integer dailyPatients = Integer.parseInt(scan.nextLine());
  20.  
  21. int temp = Math.min(dailyPatients, doctors);
  22. hostedPatients += temp;
  23. nonhostedPatients += (dailyPatients - temp);
  24. }
  25.  
  26. System.out.println("Treated patients: " + hostedPatients + ".");
  27. System.out.println("Untreated patients: " + nonhostedPatients + ".");
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement