Bangeev

Untitled

Nov 22nd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. $flowers = strval(readline());
  4. $numFlowers = intval(readline());
  5. $budget = intval(readline());
  6. $flowersPrice = 0;
  7.  
  8. switch ($flowers) {
  9.     case "Roses": $flowersPrice = 5;
  10.         break;
  11.    case "Dahlias": $flowersPrice = 3.80;
  12.         break;
  13.     case "Tulips": $flowersPrice = 2.80;
  14.         break;
  15.     case "Narcissus": $flowersPrice = 3;
  16.         break;
  17.     case "Gladiolus": $flowersPrice = 2.50;
  18.         break;
  19. default:
  20.      break;
  21. }
  22.  
  23. $totalPrice = $flowersPrice * $numFlowers;
  24.  
  25. if ($numFlowers > 80 && $flowers == "Roses") {
  26.     $totalPrice = $totalPrice - ($totalPrice * 0.10);
  27. }elseif ($numFlowers > 90 && $flowers == "Dahlias") {
  28.     $totalPrice = $totalPrice - ($totalPrice * 0.15);
  29. }elseif ($numFlowers > 80 && $flowers == "Tulips") {
  30.     $totalPrice = $totalPrice - ($totalPrice * 0.15);
  31. }elseif ($numFlowers < 120 && $flowers == "Narcissus") {
  32.     $totalPrice = $totalPrice + ($totalPrice * 0.15);
  33. }elseif ($numFlowers < 80 && $flowers == "Gladiolus") {
  34.     $totalPrice = $totalPrice + ($totalPrice * 0.20);
  35. }
  36.  
  37.  
  38. if ($budget < $totalPrice) {
  39.     printf("Not enough money, you need %.2f leva more.", abs($budget - $totalPrice));
  40. } else {
  41.     printf("Hey, you have a great garden with %.0f %s and %.2f leva left.", $numFlowers , $flowers, abs($budget - $totalPrice));
  42. }
Advertisement
Add Comment
Please, Sign In to add comment