TheBulgarianWolf

Random switch statement v2.0

Dec 11th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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 _11._12._2019
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Enter a profession and you will get the best possible drink: ");
  14.             string prof = Console.ReadLine();
  15.             Console.WriteLine("Enter the amount of drinks you want to buy: ");
  16.             int quantity = int.Parse(Console.ReadLine());
  17.            
  18.             double price;
  19.             switch (prof)
  20.             {
  21.                 case "Athlete":
  22.                     price = 0.7;
  23.                     break;
  24.                 case "Businessman":
  25.                 case "Businesswoman":
  26.                     price = 1;
  27.                     break;
  28.                 case "SoftUni student":
  29.                     price = 1.7;
  30.                     break;
  31.                 default:
  32.                     price = 2.1;
  33.                     break;
  34.             }
  35.             Console.WriteLine($"The {prof} has to pay {price*quantity:F2}$");
  36.             Console.ReadLine();
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment