silvana1303

fitness card

May 2nd, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int budget = int.Parse(Console.ReadLine());
  10.             char sex = char.Parse(Console.ReadLine());
  11.             int age = int.Parse(Console.ReadLine());
  12.             string sport = Console.ReadLine();
  13.             double price = 0.0;
  14.  
  15.             if (sex == 'm')
  16.             {
  17.                 if (sport == "Gym")
  18.                 {
  19.                     price = 42;
  20.                 }
  21.                 else if (sport == "Boxing")
  22.                 {
  23.                     price = 41;
  24.                 }
  25.                 else if (sport == "Yoga")
  26.                 {
  27.                     price = 45;
  28.                 }
  29.                 else if (sport == "Zumba")
  30.                 {
  31.                     price = 34;
  32.                 }
  33.                 else if (sport == "Dances")
  34.                 {
  35.                     price = 51;
  36.                 }
  37.                 else
  38.                 {
  39.                     price = 39;
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 if (sport == "Gym")
  45.                 {
  46.                     price = 35;
  47.                 }
  48.                 else if (sport == "Boxing")
  49.                 {
  50.                     price = 37;
  51.                 }
  52.                 else if (sport == "Yoga")
  53.                 {
  54.                     price = 42;
  55.                 }
  56.                 else if (sport == "Zumba")
  57.                 {
  58.                     price = 31;
  59.                 }
  60.                 else if (sport == "Dances")
  61.                 {
  62.                     price = 53;
  63.                 }
  64.                 else
  65.                 {
  66.                     price = 37;
  67.                 }
  68.             }
  69.  
  70.             if (age <= 19)
  71.             {
  72.                 price *= 0.80;
  73.             }
  74.  
  75.             if (price <= budget)
  76.             {
  77.                 Console.WriteLine($"You purchased a 1 month pass for {sport}.");
  78.             }
  79.             else
  80.             {
  81.                 Console.WriteLine($"You don't have enough money! You need ${price-budget:F2} more.");
  82.             }
  83.         }
  84.     }
  85. }
Add Comment
Please, Sign In to add comment