Advertisement
Guest User

Untitled

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