Advertisement
aleahim

FruitMarket_14.04.2014_SoftUni

Apr 15th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 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. class FruitMarket
  8. {
  9.     static void Main()
  10.     {
  11.         double quantity;
  12.         string product;
  13.         double fruits = 0.0;
  14.         double vegs = 0.0;
  15.         double bananas = 0.0;
  16.  
  17.         string day = Console.ReadLine();
  18.         for (int i = 0; i < 3; i++ )
  19.         {
  20.             quantity = double.Parse(Console.ReadLine());
  21.             product = Console.ReadLine();
  22.             double current_sum = 0.0 ;
  23.  
  24.             if (product == "banana")
  25.             {
  26.                 current_sum = quantity * 1.80;
  27.                 bananas = current_sum;
  28.                 fruits += current_sum;
  29.                  
  30.             }
  31.             else if (product == "cucumber")
  32.             {
  33.                 current_sum = quantity * 2.75;
  34.                 vegs += current_sum;
  35.             }
  36.             else if (product == "tomato")
  37.             {
  38.                 current_sum = quantity * 3.20;
  39.                 vegs += current_sum;
  40.             }
  41.             else if (product == "orange")
  42.             {
  43.                 current_sum = quantity * 1.60;
  44.                 fruits += current_sum;
  45.             }
  46.             else if (product == "apple")
  47.             {
  48.                 current_sum = quantity * 0.86;
  49.                 fruits += current_sum;
  50.             }          
  51.         }
  52.  
  53.         //calculate discount
  54.         double total = fruits + vegs;
  55.         double off = 0.0;
  56.         if (day == "Friday")
  57.         {
  58.             off = (fruits + vegs) / 10;
  59.         }
  60.         else if (day == "Sunday")
  61.         {
  62.             off = (fruits + vegs) / 20;
  63.         }
  64.         else if (day == "Tuesday")
  65.         {
  66.             off = fruits / 5;
  67.         }
  68.         else if (day == "Wednesday")
  69.         {
  70.             off = vegs / 10;
  71.         }
  72.         else if (day == "Thursday")
  73.         {
  74.             off = (bananas * 3) / 10;
  75.         }
  76.         double result = total - off;
  77.         Console.WriteLine("{0:0.00}",Math.Round(result, 2));
  78.         Console.ReadLine();
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement