Advertisement
Niicksana

Dwarf Presents

Jan 2nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 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 _4.Dwarf_Presents
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Programming Basics Exam - 16 December 2017
  14.             int draws = int.Parse(Console.ReadLine());
  15.             int money = int.Parse(Console.ReadLine());
  16.  
  17.             int sandClock = 0;
  18.             int magnet = 0;
  19.             int cup = 0;
  20.             int tShirt = 0;
  21.  
  22.             for (int i = 1; i <= draws; i++)
  23.             {
  24.                 string presesnt = Console.ReadLine();
  25.  
  26.                 if (presesnt == "sand clock")
  27.                 {
  28.                     sandClock += 1;
  29.                 }
  30.  
  31.                 else if (presesnt == "magnet")
  32.                 {
  33.                     magnet += 1;
  34.                 }
  35.  
  36.                 else if (presesnt == "cup")
  37.                 {
  38.                     cup += 1;
  39.                 }
  40.  
  41.                 else
  42.                 {
  43.                     tShirt += 1;
  44.                 }
  45.             }
  46.  
  47.             double price = (2.20 * sandClock) + (1.50 * magnet) +
  48.                                  (5.00 * cup) + (10.00 * tShirt);
  49.  
  50.             double moneyLeft = money - price;
  51.  
  52.             if (moneyLeft >= 0)
  53.             {
  54.                 Console.WriteLine("Santa Claus has {0:f2} more leva left!", (money - price));
  55.             }
  56.  
  57.             else
  58.             {
  59.                 Console.WriteLine("Santa Claus will need {0:f2} more leva.", (price - money));
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement