Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 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(string[] args)
  12.         {
  13.  
  14.             var fruit = Console.ReadLine().ToLower();
  15.             var day = Console.ReadLine().ToLower();
  16.             var quantity = decimal.Parse(Console.ReadLine());
  17.  
  18.            
  19.             string[] array1 = { "banana", "apple", "orange", "grapefruit", "kiwi", "pineapple", "grapes" };
  20.             decimal[] prices = { 2.50M, 1.20M, 0.85M, 1.45M, 2.70M, 5.50M, 3.85M };
  21.             decimal[] prices1 = { 2.70M, 1.25M, 0.90M, 1.60M, 3.00M, 5.60M, 4.20M };
  22.  
  23.             if ((day == "monday"|| day == "tuesday"|| day == "wednesday"|| day == "thursday"|| day == "friday")&&
  24.                 (fruit == "banana" || fruit == "apple" || fruit == "orange" || fruit == "grapefruit" || fruit == "kiwi" || fruit == "pineapple" || fruit == "grapes"))
  25.             {
  26.                 for (int i = 0; i < array1.Length; i++)
  27.                 {
  28.                     if (array1[i] == fruit)
  29.                     {
  30.                         decimal sum = prices[i];
  31.                         Console.WriteLine(Math.Round((sum * quantity), 2));
  32.                     }
  33.                 }
  34.  
  35.             }
  36.             else if (day == "saturday"|| day == "sunday")
  37.             {
  38.  
  39.                 for (int i = 0; i < array1.Length; i++)
  40.                 {
  41.                     if (array1[i] == fruit)
  42.                     {
  43.                         decimal sum = prices1[i];
  44.                         Console.WriteLine(Math.Round ((sum * quantity),2));
  45.                     }
  46.                 }
  47.             }
  48.             else
  49.             {
  50.                 Console.WriteLine("error");
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement