Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.69 KB | None | 0 0
  1. using System;
  2.     class Program
  3.     {
  4.         static void Main(string[] args)
  5.         {
  6.             string fruit = Console.ReadLine().ToLower();
  7.             string day = Console.ReadLine().ToLower();
  8.             var unit = double.Parse(Console.ReadLine());
  9.  
  10.             var price = -1.0;
  11.  
  12.             //Тук в if-a "wednesdy" е сбъркано, трябва да е "wednesday"
  13.             if (day == "monday" || day == "tuesday" || day == "wednesdy" || day == "thursday" || day == "friday")
  14.             {
  15.                 if (fruit == "banana")
  16.                 {
  17.                     price = 2.50;
  18.                 }
  19.                 else if (fruit == "apple")
  20.                 {
  21.                     price = 1.20;
  22.                 }
  23.                 else if (fruit == "orange")
  24.                 {
  25.                     price = 0.85;
  26.                 }
  27.                 else if (fruit == "grapefruit")
  28.                 {
  29.                     price = 1.45;
  30.                 }
  31.                 else if (fruit == "kiwi")
  32.                 {
  33.                     price = 2.70;
  34.                 }
  35.                 else if (fruit == "pineapple")
  36.                 {
  37.                     price = 5.50;
  38.                 }
  39.                 else if (fruit == "grapes")
  40.                 {
  41.                     price = 3.85;
  42.                 }
  43.                
  44.             }
  45.             //Тук в if-a имаш 1 спейс повече в "saturday ", трябва да е "saturday"
  46.             if (day == "saturday " || day == "sunday")
  47.             {
  48.                 if (fruit == "banana")
  49.                 {
  50.                     price = 2.70;
  51.                 }
  52.                 else if (fruit == "apple")
  53.                 {
  54.                     price = 1.25;
  55.                 }
  56.                 else if (fruit == "orange")
  57.                 {
  58.                     price = 0.90;
  59.                 }
  60.                 //Тук в else if-a имаш си сбъркал "arapegruit", трябва да е "grapefruit"
  61.                 else if (fruit == "arapefruit")
  62.                 {
  63.                     price = 1.60;
  64.                 }
  65.                 else if (fruit == "kiwi")
  66.                 {
  67.                     price = 3.00;
  68.                 }
  69.                 else if (fruit == "pineapple")
  70.                 {
  71.                     price = 5.60;
  72.                 }
  73.                 else if (fruit == "grapes")
  74.                 {
  75.                     price = 4.20;
  76.                 }
  77.             }
  78.             if (price >= 0)
  79.             {
  80.                 Console.WriteLine("{0:F2}", price * unit);
  81.             }
  82.             else
  83.             {
  84.                 Console.WriteLine("error");
  85.             }
  86.         }
  87.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement