Advertisement
MiroslavKisov

FruitShopFixed

Dec 13th, 2017
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 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()
  12.         {
  13.             string fruit = Console.ReadLine();
  14.             string day = Console.ReadLine();
  15.             var quantity = double.Parse(Console.ReadLine());
  16.             var price = 0.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.             }
  49.             else if (day == "Saturday" || day == "Sunday")
  50.             {
  51.                 if (fruit == "banana")
  52.                 {
  53.                     price = 2.70;
  54.                 }
  55.                 else if (fruit == "apple")
  56.                 {
  57.                     price = 1.25;
  58.                 }
  59.                 else if (fruit == "orange")
  60.                 {
  61.                     price = 0.90;
  62.                 }
  63.                 else if (fruit == "grapefruit")
  64.                 {
  65.                     price = 1.60;
  66.                 }
  67.                 else if (fruit == "kiwi")
  68.                 {
  69.                     price = 3.00;
  70.                 }
  71.                 else if (fruit == "pineapple")
  72.                 {
  73.                     price = 5.60;
  74.                 }
  75.                 else if (fruit == "grapes")
  76.                 {
  77.                     price = 4.20;
  78.                 }
  79.             }
  80.             var total = price * quantity;
  81.             if (total != 0.0d)
  82.             {
  83.                 Console.WriteLine("{0:F2}", total);
  84.             }
  85.             else
  86.             {
  87.                 Console.WriteLine("error");
  88.             }
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement