VelizarAvramov

07. Fruit Shop

Mar 21st, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07_fruitshop2
  8. {
  9.     class fruitShoptwo
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var fruit = Console.ReadLine().ToLower();
  14.             var day = Console.ReadLine().ToLower();
  15.             var quantity = double.Parse(Console.ReadLine());
  16.             var price = -1.0;
  17.  
  18.             if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday")
  19.             {
  20.                 if (fruit == "banana")
  21.                 {
  22.                     price =  2.50;
  23.                 }
  24.                 else if (fruit == "apple")
  25.                 {
  26.                     price = 1.20;
  27.                 }
  28.                 else if (fruit == "orange")
  29.                 {
  30.                     price = 0.85;
  31.                 }
  32.                 else if (fruit == "grapefruit")
  33.                 {
  34.                     price = 1.45;
  35.                 }
  36.                 else if (fruit == "kiwi")
  37.                 {
  38.                     price = 2.70;
  39.                 }
  40.                 else if (fruit == "pineapple")
  41.                 {
  42.                     price = 5.50;
  43.                 }
  44.                 else if (fruit == "grapes")
  45.                 {
  46.                     price = 3.85;
  47.                 }
  48.                 else
  49.                 {
  50.                     Console.WriteLine("error");
  51.                 }
  52.             }
  53.             else if (day == "saturday" || day == "sunday")
  54.             {
  55.                 if (fruit == "banana")
  56.                 {
  57.                     price = 2.70;
  58.                 }
  59.                 else if (fruit == "apple")
  60.                 {
  61.                     price = 1.25;
  62.                 }
  63.                 else if (fruit == "orange")
  64.                 {
  65.                     price = 0.90;
  66.                 }
  67.                 else if (fruit == "grapefruit")
  68.                 {
  69.                     price = 1.60;
  70.                 }
  71.                 else if (fruit == "kiwi")
  72.                 {
  73.                     price = 3.00;
  74.                 }
  75.                 else if (fruit == "pineapple")
  76.                 {
  77.                     price = 5.60;
  78.                 }
  79.                 else if (fruit == "grapes")
  80.                 {
  81.                     price = 4.20;
  82.                 }
  83.             }
  84.             else
  85.             {
  86.                 Console.WriteLine("error");
  87.             }
  88.             Console.WriteLine("{0:f2}" , price * quantity);
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment