Advertisement
Guest User

Fruit shop

a guest
Feb 26th, 2020
1,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.66 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 Fruit_Shop
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // плод  banana  apple    orange  grapefruit kiwi   pineapple grapes
  14.             //цена    2.50    1.20    0.85    1.45    2.70    5.50    3.85
  15.  
  16.             //    Събота и неделя магазинът работи на по - високи цени:
  17.             // плод  banana   apple   orange  grapefruit kiwi   pineapple grapes
  18.             //цена    2.70    1.25    0.90    1.60    3.00    5.60    4.20
  19.  
  20.             //въведени от потребителя, и пресмята цената според цените от таблиците по-горе.Резултатът да се отпечата закръглен с 2 цифри
  21.             //    след десетичната точка. При невалиден ден от седмицата или невалидно име на плод да се отпечата "error".
  22.  
  23.             string fruit = Console.ReadLine();
  24.             string day = Console.ReadLine();
  25.             double quantity = double.Parse(Console.ReadLine());
  26.             double price = 0;
  27.  
  28.             if (day == "Saturday" || day == "Sunday")
  29.             {
  30.                 if (fruit == "banana") price = 2.70;
  31.                 else if (fruit == "apple") price = 1.25;              
  32.                 else if (fruit == "orange") price = 0.90;                                                  
  33.                 else if (fruit == "grapefruit") price = 1.60;                                                  
  34.                 else if (fruit == "kiwi") price = 3.00;
  35.                 else if (fruit == "pineapple") price = 5.60;
  36.                 else if (fruit == "grapes") price = 4.20;                                                  
  37.             }
  38.             else if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday")
  39.             {
  40.                 if (fruit == "banana") price = 2.50;
  41.                 else if (fruit == "apple") price = 1.20;
  42.                 else if (fruit == "orange") price = 0.85;
  43.                 else if (fruit == "grapefruit") price = 1.45;
  44.                 else if (fruit == "kiwi") price = 2.70;
  45.                 else if (fruit == "pineapple") price = 5.50;
  46.                 else if (fruit == "grapes") price = 3.85;
  47.             }          
  48.             else
  49.             {
  50.                 Console.WriteLine("error");
  51.             }
  52.  
  53.             Console.WriteLine($"{price * quantity:f2}");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement