Yachkov

Fruit Shop

Jan 25th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.37 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel.Design;
  3. using System.Globalization;
  4. using System.Reflection;
  5. using System.Runtime.ConstrainedExecution;
  6. using System.Security.Cryptography;
  7.  
  8. namespace SomeExcercises
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             //           Напишете програма, която чете от конзолата плод (banana / apple / orange / grapefruit / kiwi /
  15.             //pineapple / grapes), ден от седмицата (Monday / Tuesday / Wednesday / Thursday / Friday /
  16.             //Saturday / Sunday) и количес;тво (реално число)
  17.             double finalPrice = 0.0;
  18.             string fruit = Console.ReadLine();
  19.             string dayOfWeek = Console.ReadLine();
  20.             double quantity = double.Parse(Console.ReadLine());
  21.  
  22.             if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek=="Wednesday" || dayOfWeek=="Thursday" || dayOfWeek == "Friday")
  23.             {
  24.  
  25.  
  26.                 switch (fruit)
  27.                 {
  28.                     case "banana":
  29.                        finalPrice = quantity * 2.50;
  30.                        Console.WriteLine($"{finalPrice:f2}");
  31.                         break;
  32.                     case "apple":
  33.                         finalPrice = (quantity * 1.20);
  34.                         Console.WriteLine($"{finalPrice:f2}");
  35.                         break;
  36.                     case "orange":
  37.                        finalPrice = (quantity * 0.85);
  38.                        Console.WriteLine($"{finalPrice:f2}");
  39.                         break;
  40.                     case "grapefruit":
  41.                         finalPrice = (quantity * 1.45);
  42.                         Console.WriteLine($"{finalPrice:f2}");
  43.                         break;
  44.                     case "kiwi":
  45.                         finalPrice = (quantity * 2.70);
  46.                         Console.WriteLine($"{finalPrice:f2}");
  47.                         break;
  48.                     case "pineapple":
  49.                         finalPrice = (quantity * 5.50);
  50.                         Console.WriteLine($"{finalPrice:f2}");
  51.                         break;
  52.                     case "grapes":
  53.                         finalPrice = (quantity * 3.85);
  54.                         Console.WriteLine($"{finalPrice:f2}");
  55.                         break;
  56.                     default:
  57.                         Console.WriteLine("error");
  58.                         break;
  59.                 }
  60.             }
  61.             else if (dayOfWeek == "Saturday" || dayOfWeek == "Sunday")
  62.             {
  63.                 switch (fruit)
  64.                 {
  65.                     case "banana":
  66.                         finalPrice = (quantity * 2.70);
  67.                         Console.WriteLine($"{finalPrice:f2}");
  68.                         break;
  69.                     case "apple":
  70.                         finalPrice = (quantity * 1.25);
  71.                         Console.WriteLine($"{finalPrice:f2}");
  72.                         break;
  73.                     case "orange":
  74.                         finalPrice = (quantity * 0.90);
  75.                         Console.WriteLine($"{finalPrice:f2}");
  76.                         break;
  77.                     case "grapefruit":
  78.                         finalPrice = (quantity * 1.60);
  79.                         Console.WriteLine($"{finalPrice:f2}");
  80.                         break;
  81.                     case "kiwi":
  82.                         finalPrice = (quantity * 3.00);
  83.                         Console.WriteLine($"{finalPrice:f2}");
  84.                         break;
  85.                     case "pineapple":
  86.                         finalPrice = (quantity * 5.60);
  87.                         Console.WriteLine($"{finalPrice:f2}");
  88.                         break;
  89.                     case "grapes":
  90.                         finalPrice = (quantity * 4.20);
  91.                         Console.WriteLine($"{finalPrice:f2}");
  92.                         break;
  93.                     default:
  94.                         Console.WriteLine("error");
  95.                         break;
  96.                 }
  97.             }
  98.  
  99.             if (dayOfWeek != "Monday" && dayOfWeek != "Tuesday" && dayOfWeek != "Wednesday" && dayOfWeek != "Thursday" && dayOfWeek != "Friday" && dayOfWeek != "Saturday" && dayOfWeek != "Sunday")
  100.             {
  101.                 Console.WriteLine("error");
  102.             }
  103.  
  104.  
  105.  
  106.         }
  107.  
  108.     }
  109. }
  110.  
  111.  
  112.  
  113.  
Advertisement
Add Comment
Please, Sign In to add comment