Advertisement
Grimmjow1

6. Fruit Shop

Feb 1st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.60 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 _7_ma
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string fruit = Console.ReadLine().ToLower();
  14.             string day = Console.ReadLine().ToLower();
  15.             double amount = double.Parse(Console.ReadLine());
  16.  
  17.             double price = 0.00;
  18.            
  19.  
  20.  
  21.             if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday")  //провека на деня
  22.             {
  23.                 if (fruit == "banana")  // провека на плод
  24.                 {
  25.                     price = amount * 2.5;  // промяна на цена  ако се изпълни
  26.                 }
  27.                 else if (fruit == "apple")
  28.  
  29.                 {
  30.                     price = amount * 1.20;
  31.                 }
  32.                 else if (fruit == "orange")
  33.  
  34.                 {
  35.                     price = amount * 0.85;
  36.                 }
  37.                 else if (fruit == "grapefruit")
  38.  
  39.                 {
  40.                     price = amount * 1.45;
  41.                 }
  42.                 else if (fruit == "kiwi")
  43.  
  44.                 {
  45.                     price = amount * 2.70;
  46.  
  47.                 }
  48.                 else if (fruit == "pineapple")
  49.  
  50.                 {
  51.                     price = amount * 5.50;
  52.                 }
  53.                 else if (fruit == "grapes")
  54.  
  55.                 {
  56.                     price = amount * 3.85;
  57.                 }
  58.                 else
  59.                 {
  60.                     Console.WriteLine("error");  // да се изпише ерор ако е въведен плод различен от посочените  в иф-а
  61.                 }
  62.  
  63.             }
  64.  
  65.  
  66.             else if (day == "saturday" || day == "sunday")
  67.             {
  68.                 if (fruit == "banana")
  69.                 {
  70.                     price = amount * 2.7;
  71.                 }
  72.                 else if (fruit == "apple")
  73.  
  74.                 {
  75.                     price = amount * 1.25;
  76.                 }
  77.                 else if (fruit == "orange")
  78.  
  79.                 {
  80.                     price = amount * 0.90;
  81.                 }
  82.                 else if (fruit == "grapefruit")
  83.  
  84.                 {
  85.                     price = amount * 1.60;
  86.                 }
  87.                 else if (fruit == "kiwi")
  88.  
  89.                 {
  90.                     price = amount * 3.00;
  91.  
  92.                 }
  93.                 else if (fruit == "pineapple")
  94.  
  95.                 {
  96.                     price = amount * 5.60;
  97.                 }
  98.                 else if (fruit == "grapes")
  99.  
  100.                 {
  101.                     price = amount * 4.20;
  102.                 }
  103.                 else
  104.                 {
  105.                     Console.WriteLine("error");  // да се изпише ерор ако е въведен плод различен от посочените  в иф-а
  106.                 }
  107.             }
  108.             else
  109.             {
  110.                 Console.WriteLine("error");  //// да се изпише ерор ако е въведен ден  различен от посочените  в иф-а
  111.             }
  112.             if (price==0)   // проверка ако  цената е 0   , да не се изпълнява нищо
  113.             {
  114.  
  115.             }
  116.             else   // но ако цената е различна от 0 да се отпечата  
  117.             {
  118.                 Console.WriteLine("{0:F2}", price);
  119.             }
  120.            
  121.  
  122.         }
  123.     }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement