svetoslav_0

04. Dwarf Presents

Jan 30th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 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 Console1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var gnoms = double.Parse(Console.ReadLine());
  14.             double money = double.Parse(Console.ReadLine());
  15.             string surprise;
  16.             double sum = 0.0;
  17.             for (int i = 0;  i < gnoms; i++)
  18.             {
  19.                 surprise = Console.ReadLine();
  20.                 if (surprise == "sand clock")
  21.                 {
  22.                     sum += 2.20;
  23.                 }
  24.                 else if (surprise == "magnet")
  25.                 {
  26.                     sum += 1.50;
  27.                 }
  28.                 else if (surprise == "cup")
  29.                 {
  30.                     sum += 5.00;
  31.                 }
  32.                 else if (surprise == "t-shirt")
  33.                 {
  34.                     sum += 10.00;
  35.                 }
  36.             }
  37.  
  38.             if (money >= sum)
  39.             {
  40.                 Console.WriteLine($"Santa Claus has {money-sum:f2} more leva left!");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine($"Santa Claus will need {sum-money:f2} more leva.");
  45.  
  46.  
  47.             }
  48.            
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment