Created
January 24, 2018 11:34
-
-
Save NastySwipy/14898e3b3f28c203de38c4e9b7ea4353 to your computer and use it in GitHub Desktop.
php - 02. Harvest Exam 17.07.2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$vineyard = intval(readline()); | |
$grapеKilograms = readline(); | |
$neededWine = intval(readline()); | |
$numWorkers = intval(readline()); | |
$totalGrape = $vineyard * $grapеKilograms; | |
$wine = 40/100 * $totalGrape / 2.5; | |
$remainderWine = $neededWine - $wine; | |
if($wine >= $neededWine){ | |
echo "Good harvest this year! Total wine: ".floor($wine)." liters."."\n"; | |
echo abs(floor($remainderWine))." liters left -> ".abs(floor($remainderWine / $numWorkers)). " liters per person."; | |
} | |
else { | |
echo "It will be a tough winter! More ".abs(floor($remainderWine))." liters wine needed."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment