Advertisement
IvanBorisovG

FruitShop

Jul 25th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.30 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 FruitShop
  8. {
  9.     class FruitShop
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string Fruit = Console.ReadLine().ToLower();
  14.             string dayOfWeek = Console.ReadLine().ToLower();
  15.             double quаntity = double.Parse(Console.ReadLine());
  16.  
  17.             string monday = "Monday";
  18.             string tuesday = "Tuesday";
  19.             string wednesday = "Wednesday";
  20.             string thursday = "Thursday";
  21.             string friday = "Friday";
  22.             string saturday = "Saturday";
  23.             string sunday = "Sunday";
  24.  
  25.             string banana = "banana";
  26.             string apple = "apple";
  27.             string orange = "orange";
  28.             string grapefruit = "grapefruit";
  29.             string kiwi = "kiwi";
  30.             string pineapple = "pineapple";
  31.             string grapes = "grapes";
  32.  
  33.             double priceOfProduct = -1.0;
  34.  
  35.  
  36.             if (dayOfWeek == monday || dayOfWeek == tuesday ||
  37.                 dayOfWeek == wednesday || dayOfWeek == thursday ||
  38.                 dayOfWeek == friday)
  39.             {
  40.                 if (Fruit == banana)
  41.                 {
  42.                     priceOfProduct = 2.50;
  43.                 }
  44.                 else if (Fruit == apple)
  45.                 {
  46.                     priceOfProduct = 1.20;
  47.                 }
  48.                 else if (Fruit == orange)
  49.                 {
  50.                     priceOfProduct = 0.85;
  51.                 }
  52.                 else if (Fruit == grapefruit)
  53.                 {
  54.                     priceOfProduct = 1.45;
  55.                 }
  56.                 else if (Fruit == kiwi)
  57.                 {
  58.                     priceOfProduct = 2.70;
  59.                 }
  60.                 else if (Fruit == pineapple)
  61.                 {
  62.                     priceOfProduct = 5.50;
  63.                 }
  64.                 else if (Fruit == grapes)
  65.                 {
  66.                     priceOfProduct = 3.85;
  67.                 }
  68.             }
  69.             else if (dayOfWeek == saturday || dayOfWeek == sunday)
  70.             {
  71.                 if (Fruit == banana)
  72.                 {
  73.                     priceOfProduct = 2.70;
  74.                 }
  75.                 else if (Fruit == apple)
  76.                 {
  77.                     priceOfProduct = 1.25;
  78.                 }
  79.                 else if (Fruit == orange)
  80.                 {
  81.                     priceOfProduct = 0.90;
  82.                 }
  83.                 else if (Fruit == grapefruit)
  84.                 {
  85.                     priceOfProduct = 1.60;
  86.                 }
  87.                 else if (Fruit == kiwi)
  88.                 {
  89.                     priceOfProduct = 3.00;
  90.                 }
  91.                 else if (Fruit == pineapple)
  92.                 {
  93.                     priceOfProduct = 5.60;
  94.                 }
  95.                 else if (Fruit == grapes)
  96.                 {
  97.                     priceOfProduct = 4.20;
  98.                 }
  99.             }
  100.             if (priceOfProduct < 0)
  101.             {
  102.                 Console.WriteLine("error");
  103.             }
  104.             else
  105.             {
  106.                 double result = quаntity * priceOfProduct;
  107.                 Console.WriteLine($"{result:f2}");
  108.             }
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement