Advertisement
kallyy7

Untitled

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