Advertisement
MartinGeorgiev

01.Gift Coverage

Jun 30th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $side = floatval(readline());
  3. $sheetCount = intval(readline());
  4. $coverPerSheet = floatval(readline());
  5.  
  6. $presentArea = pow($side, 2) * 6;
  7. $coverTotal = 0;
  8. while ($sheetCount > 0) {
  9.     if ($sheetCount % 3 == 0) {
  10.         $coverTotal += $coverPerSheet * 0.25;
  11.     } else {
  12.         $coverTotal += $coverPerSheet;
  13.  
  14.     }
  15.     $sheetCount--;
  16. }
  17. $percent = ($coverTotal / $presentArea) * 100;
  18. printf("You can cover %.2f%% of the box.", $percent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement