Advertisement
dimipan80

Exam 7. Fruit Market

Jun 20th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Threading;
  5.  
  6. public class FruitMarket
  7. {
  8.     public static void Main()
  9.     {
  10.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  11.         checked
  12.         {
  13.             string dayOfWeek = Console.ReadLine();
  14.            
  15.             Dictionary<string, decimal> priceList = new Dictionary<string, decimal>();
  16.             priceList["banana"] = 1.80m;
  17.             priceList["cucumber"] = 2.75m;
  18.             priceList["tomato"] = 3.20m;
  19.             priceList["orange"] = 1.60m;
  20.             priceList["apple"] = 0.86m;
  21.            
  22.             decimal totalPrice = 0;
  23.             for (int i = 0; i < 3; i++)
  24.             {
  25.                 decimal quantity = decimal.Parse(Console.ReadLine());
  26.                 string product = Console.ReadLine();
  27.                 decimal productPrice = priceList[product];
  28.                 switch (dayOfWeek)
  29.                 {
  30.                     case "Friday":
  31.                         productPrice *= 0.90m;
  32.                         break;
  33.                     case "Sunday":
  34.                         productPrice *= 0.95m;
  35.                         break;
  36.                     case "Tuesday":
  37.                         if (product == "banana" || product == "orange" || product == "apple")
  38.                         {
  39.                             productPrice *= 0.80m;
  40.                         }
  41.                        
  42.                         break;
  43.                     case "Wednesday":
  44.                         if (product == "cucumber" || product == "tomato")
  45.                         {
  46.                             productPrice *= 0.90m;
  47.                         }
  48.  
  49.                         break;
  50.                     case "Thursday":
  51.                         if (product == "banana")
  52.                         {
  53.                             productPrice *= 0.70m;
  54.                         }
  55.  
  56.                         break;                    
  57.                 }
  58.  
  59.                 totalPrice += quantity * productPrice;
  60.             }
  61.  
  62.             Console.WriteLine("{0:f2}", totalPrice);
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement