Advertisement
IvanITD

01.Cinema

Jan 16th, 2024
851
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | Source Code | 0 0
  1. string typeOfProjection = Console.ReadLine();
  2. int lineAmmount = int.Parse(Console.ReadLine());
  3. int columnsAmmount = int.Parse(Console.ReadLine());
  4.  
  5. double result = 0.00;
  6.  
  7. // Here we resolved the task with the if else statement
  8. if (typeOfProjection == "Premiere")
  9. {
  10.     double premierePrice = 12.00;
  11.     result = lineAmmount * columnsAmmount * premierePrice;
  12. }
  13. else if (typeOfProjection == "Normal")
  14. {
  15.     double normalPrice = 7.50;
  16.     result = lineAmmount * columnsAmmount * normalPrice;
  17. }
  18. else if (typeOfProjection == "Discount")
  19. {
  20.     double discountPrice = 5.00;
  21.     result = lineAmmount * columnsAmmount * discountPrice;
  22. }
  23. Console.WriteLine($"{result:F2} leva");
  24.  
  25. //Here we resolved the task with the switch case statement
  26.  
  27. switch (typeOfProjection)
  28. {
  29.     case "Premiere":
  30.         double premierePrice = 12.00;
  31.         result = lineAmmount * columnsAmmount * premierePrice;
  32.         break;
  33.  
  34.     case "Normal":
  35.         double normalPrice = 7.50;
  36.         result = lineAmmount * columnsAmmount * normalPrice;
  37.         break;
  38.  
  39.     case "Discount":
  40.         double discountPrice = 5.00;
  41.         result = lineAmmount * columnsAmmount * discountPrice;
  42.         break;
  43. }
  44. Console.WriteLine($"{result:F2} leva");
  45.  
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement