Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. function shop(input) {
  2.     let fruit = String(input[0]).toLowerCase();
  3.     let day = String(input[1]).toLowerCase();
  4.     let quantity = Number(input[2]);
  5.  
  6.     let price = -1;
  7.  
  8.     if (day == "monday" || day == "tuesday" || day == "thursday" || day == "friday" || day == "wednesday") {
  9.         if (fruit == "banana") {
  10.             price = 2.50;
  11.         }
  12.         else if (fruit == "apple") {
  13.             price = 1.20;
  14.         }
  15.         else if (fruit == "orange") {
  16.             price = 0.85;
  17.         }
  18.         else if (fruit == "grapefruit") {
  19.             price = 1.45;
  20.         }
  21.         else if (fruit == "kiwi") {
  22.             price = 2.70;
  23.         }
  24.         else if (fruit == "pineapple") {
  25.             price = 5.50;
  26.         }
  27.         else if (fruit == "grapes") {
  28.             price = 3.85;
  29.         }
  30.     }
  31.     else if (day == "saturday" || day == "sunday") {
  32.         if (fruit == "banana") {
  33.             price = 2.70;
  34.         }
  35.         else if (fruit == "apple") {
  36.             price = 1.25;
  37.         }
  38.         else if (fruit == "orange") {
  39.             price = 0.90;
  40.         }
  41.         else if (fruit == "grapefruit") {
  42.             price = 1.60;
  43.         }
  44.         else if (fruit == "kiwi") {
  45.             price = 3.00;
  46.         }
  47.         else if (fruit == "pineapple") {
  48.             price = 5.60;
  49.         }
  50.         else if (fruit == "grapes") {
  51.             price = 4.20;
  52.         }
  53.     }
  54.     if (price >= 0) {
  55.         console.log(quantity * price);
  56.     }
  57.     else {
  58.         console.log('error')
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement