Advertisement
Samorokimetal

Bolnica

Jan 5th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Bolnica {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         System.out.print("Period: ");
  9.         int period = Integer.parseInt(scanner.nextLine());
  10.         if (!(period >= 1 && period <= 1000)) {
  11.             return;
  12.         }
  13.  
  14.         int treatedPatients = 0;
  15.         int untreatedPatients = 0;
  16.         int doctors = 7;
  17.  
  18.         for (int day = 1; day <= period; day++) {
  19.             System.out.printf("Number of patients for day %d: ", day);
  20.             int currentPatients = Integer.parseInt(scanner.nextLine());
  21.             if ((day % 3 == 0) && (untreatedPatients > treatedPatients)) {
  22.                 doctors++;
  23.             }
  24.             if (currentPatients > doctors) {
  25.                 treatedPatients += doctors;
  26.                 untreatedPatients += currentPatients - doctors;
  27.             } else {
  28.                 treatedPatients += currentPatients;
  29.             }
  30.         }
  31.         System.out.println();
  32.         System.out.println("Number of treated patients: " + treatedPatients);
  33.         System.out.print("Number of untreated patients: " + untreatedPatients);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement