desito07

11. Fruit Shop

Nov 14th, 2022 (edited)
792
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.  
  3. namespace Conditional_Statements_Advanced
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string fruit = Console.ReadLine();
  10.             string day = Console.ReadLine();
  11.             double quantity = double.Parse(Console.ReadLine());
  12.  
  13.             if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday")
  14.             {
  15.                 if (fruit == "banana")
  16.                 {
  17.                     quantity *= 2.5;
  18.                 }
  19.                 else if (fruit == "apple")
  20.                 {
  21.                     quantity *= 1.2;
  22.                 }
  23.                 else if (fruit == "orange")
  24.                 {
  25.                     quantity *= 0.85;
  26.                 }
  27.                 else if (fruit == "grapefruit")
  28.                 {
  29.                     quantity *= 1.45;
  30.                 }
  31.                 else if (fruit == "kiwi")
  32.                 {
  33.                     quantity *= 2.7;
  34.                 }
  35.                 else if (fruit == "pineapple")
  36.                 {
  37.                     quantity *= 5.5;
  38.                 }
  39.                 else if (fruit == "grapes")
  40.                 {
  41.                     quantity *= 3.85;
  42.                 }
  43.  
  44.             }
  45.             else if (day == "Saturday" || day == "Sunday")
  46.             {
  47.  
  48.                 if (fruit == "banana")
  49.                 {
  50.                     quantity *= 2.7;
  51.                 }
  52.                 else if (fruit == "apple")
  53.                 {
  54.                     quantity *= 1.25;
  55.                 }
  56.                 else if (fruit == "orange")
  57.                 {
  58.                     quantity *= 0.90;
  59.                 }
  60.                 else if (fruit == "grapefruit")
  61.                 {
  62.                     quantity *= 1.60;
  63.                 }
  64.                 else if (fruit == "kiwi")
  65.                 {
  66.                     quantity *= 3.0;
  67.                 }
  68.                 else if (fruit == "pineapple")
  69.                 {
  70.                     quantity *= 5.6;
  71.                 }
  72.                 else if (fruit == "grapes")
  73.                 {
  74.                     quantity *= 4.20;
  75.                 }
  76.  
  77.             }
  78.  
  79.             if ((day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday" || day == "Saturday" || day == "Sunday") && (fruit == "banana" || fruit == "apple" || fruit == "orange" || fruit == "grapefruit" || fruit == "kiwi" || fruit == "pineapple" || fruit == "grapes"))
  80.             {
  81.                 Console.WriteLine($"{quantity:f2}");
  82.             }
  83.             else
  84.             {
  85.  
  86.                 Console.WriteLine("error");
  87.             }
  88.  
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment