Programming-Basics-Book-CSharp-EN

Calculating the Number of Treated and Untreated Patients

With the help of a for loop we iterate through all days in the given period (period). For each day, we read from the console the number of the patients (currentPatients). Increasing doctors by requirements can be done every third day, BUT only if the count of untreated patients is greater than the count of treated ones. For this purpose, we check if the day is third one – with the arithmetical operator for division with remainder (%): day % 3 == 0.

For example:

If day % 3 == 0 returns true, the system will check whether the count of untreated patients is greater than the count of treated ones: untreatedPatients > treatedPatients. If the result is again true, then the count of doctors will be increased (countOfDoctors).

Then we check if the count of the patients for the day (currentPatients) is greater than the count of doctors (countOfDoctors). If the count of the patients is greater:

If the count of patients is not greater, increase only the variable treatedPatients with the count of patients for the day (currentPatients).

Finally we need to print the count of treated and count of untreated patients.

Testing in the Judge System

Test your solution here: https://judge.softuni.org/Contests/Practice/Index/511#3.