VladoG

PB-BG-Oct2018-ExamPrep-03.FootballSouvenirs

Nov 24th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.FootballSouvenirs
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string teamName = Console.ReadLine();
  10.             string souvenirs = Console.ReadLine();
  11.             int qty = int.Parse(Console.ReadLine());
  12.             bool isValidCountry = true;
  13.             bool isValidSouvenir = true;
  14.             double totalSum = 0.0;
  15.  
  16.             switch (teamName)
  17.             {
  18.                 case "Argentina":
  19.                     switch (souvenirs)
  20.                     {
  21.                         case "flags":
  22.                             totalSum = qty * 3.25;
  23.                             break;
  24.                         case "caps":
  25.                             totalSum = qty * 7.2;
  26.                             break;
  27.                         case "posters":
  28.                             totalSum = qty * 5.1;
  29.                             break;
  30.                         case "stickers":
  31.                             totalSum = qty * 1.25;
  32.                             break;
  33.                         default:
  34.                             isValidSouvenir = false;
  35.                             break;
  36.                     }
  37.                     break;
  38.                 case "Brazil":
  39.                     switch (souvenirs)
  40.                     {
  41.                         case "flags":
  42.                             totalSum = qty * 4.2;
  43.                             break;
  44.                         case "caps":
  45.                             totalSum = qty * 8.5;
  46.                             break;
  47.                         case "posters":
  48.                             totalSum = qty * 5.35;
  49.                             break;
  50.                         case "stickers":
  51.                             totalSum = qty * 1.2;
  52.                             break;
  53.                         default:
  54.                             isValidSouvenir = false;
  55.                             break;
  56.                     }
  57.                     break;
  58.                 case "Croatia":
  59.                     switch (souvenirs)
  60.                     {
  61.                         case "flags":
  62.                             totalSum = qty * 2.75;
  63.                             break;
  64.                         case "caps":
  65.                             totalSum = qty * 6.9;
  66.                             break;
  67.                         case "posters":
  68.                             totalSum = qty * 4.95;
  69.                             break;
  70.                         case "stickers":
  71.                             totalSum = qty * 1.1;
  72.                             break;
  73.                         default:
  74.                             isValidSouvenir = false;
  75.                             break;
  76.                     }
  77.                     break;
  78.                 case "Denmark":
  79.                     switch (souvenirs)
  80.                     {
  81.                         case "flags":
  82.                             totalSum = qty * 3.1;
  83.                             break;
  84.                         case "caps":
  85.                             totalSum = qty * 6.5;
  86.                             break;
  87.                         case "posters":
  88.                             totalSum = qty * 4.8;
  89.                             break;
  90.                         case "stickers":
  91.                             totalSum = qty * 0.9;
  92.                             break;
  93.                         default:
  94.                             isValidSouvenir = false;
  95.                             break;
  96.                     }
  97.                     break;
  98.                 default:
  99.                     isValidCountry = false;
  100.                     break;
  101.             }
  102.  
  103.             if (isValidCountry && isValidSouvenir)
  104.             {
  105.                 Console.WriteLine($"Pepi bought {qty} {souvenirs} of {teamName} for {totalSum:F2} lv.");
  106.             }
  107.             else
  108.             {
  109.                 if (!isValidCountry)
  110.                 {
  111.                     Console.WriteLine("Invalid country!");
  112.                 }
  113.                 else
  114.                 {
  115.                     Console.WriteLine("Invalid stock!");
  116.                 }
  117.             }
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment