desislava_topuzakova

Hospital

Oct 8th, 2021
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hospital {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int days = Integer.parseInt(scanner.nextLine());
  8. int doctors = 7;
  9. double treated = 0;
  10. double untreated = 0;
  11.  
  12. for (int i = 1; i <= days; i++) {
  13. int patients = Integer.parseInt(scanner.nextLine());
  14. if (i % 3 == 0 && untreated > treated) {
  15. doctors += 1;
  16. }
  17. if (patients < doctors) {
  18. treated += patients;
  19. } else {
  20. treated += doctors;
  21. untreated += patients - doctors;
  22. }
  23. }
  24. System.out.printf("Treated patients: %.0f.", treated);
  25. System.out.printf("%n Untreated patients: %.0f.", untreated);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment