Advertisement
Guest User

03. Arena Tournament PHP

a guest
Mar 13th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2. $points = floatval(readline());
  3. $arenaName = readline();
  4. $day = readline();
  5. $contition = readline();
  6. $priceForAll = 0;
  7.  
  8. $discount = 0;
  9.  
  10. if($arenaName == "Nagrand"){
  11.     if($day == "Monday" || $day =="Wednesday") {
  12.         $discount = 0.05;
  13.     }
  14.  
  15. }elseif ($arenaName == "Gurubashi"){
  16.     if($day == "Tuesday" || $day =="Thursday") {
  17.         $discount = 0.10;
  18.     }
  19.  
  20. }elseif ($arenaName == "Dire Maul"){
  21.         if($day == "Friday" || $day =="Saturday"){
  22.             $discount = 0.07;
  23.         }
  24.  
  25. }
  26.  
  27. if($contition == "Poor"){
  28.     $priceForAll = 7000 - 7000 * $discount;
  29. }elseif ($contition == "Normal"){
  30.     $priceForAll = 14000 - 14000 * $discount;
  31. }elseif ($contition == "Legendary"){
  32.     $priceForAll = 21000 - 21000 * $discount;
  33. }
  34.  
  35. //echo $priceForAll;
  36. $priceForOne = $priceForAll/5;
  37. $j=0;
  38. for ($i= 0; $i<5 ;$i++){
  39.     if($points < $priceForOne){
  40.         //$j++;
  41.         break;
  42.     }else{
  43.         $points -=$priceForOne;
  44.         $j++;
  45.     }
  46.  
  47.  
  48.  
  49. }
  50.  
  51. if($j==5){
  52.     printf("Items bought: %.0f\nArena points left: %.0f\nSuccess!",$j,$points);
  53. }else{
  54.     printf("Items bought: %.0f\nArena points left: %.0f\nFailure!",$j,$points);
  55. }
  56. //echo $points;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement