Advertisement
Ivan_Bochev

Kursova Rabota-Zadacha 4

Dec 3rd, 2018 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package kr_1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class KursovaRabotaZadacha4 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int period = Integer.parseInt(scanner.nextLine());
  9.         System.out.println();
  10.         int treatedPatients = 0;
  11.         int untreatedPatients = 0;
  12.         int countOfDoctors = 7;
  13.  
  14.         for (int day = 1; day <= period; day++) {
  15.             int CurrentPatients = Integer.parseInt(scanner.nextLine());
  16.  
  17.             if ((day % 3 == 0) && (untreatedPatients > treatedPatients)) {
  18.                 countOfDoctors++;
  19.             }
  20.             if (CurrentPatients > countOfDoctors) {
  21.                 treatedPatients += countOfDoctors;
  22.                 untreatedPatients += CurrentPatients - countOfDoctors;
  23.             } else {
  24.                 treatedPatients += CurrentPatients;
  25.             }
  26.         }
  27.         System.out.println("Treated patients: " + treatedPatients + ".");
  28.         System.out.println("Untreated patients: " + untreatedPatients + ".");
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement