Advertisement
ElviraPetkova

Christmas Gifts

Jan 14th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         string command = Console.ReadLine();
  8.        
  9.         int counterOfKids = 0;
  10.         int counterOfAdults = 0;
  11.         double moneyForToys = 0; //for kids
  12.         double moneyForSweaters = 0; //for adult
  13.        
  14.         while(command != "Christmas")
  15.         {
  16.             int age = int.Parse(command);
  17.             if(age <= 16)
  18.             {
  19.                 counterOfKids++;
  20.                 moneyForToys += 5;
  21.             }
  22.             else
  23.             {
  24.                 counterOfAdults++;
  25.                 moneyForSweaters += 15;
  26.             }
  27.            
  28.             command = Console.ReadLine();
  29.         }
  30.        
  31.         Console.WriteLine("Number of adults: {0}", counterOfAdults);
  32.         Console.WriteLine("Number of kids: {0}", counterOfKids);
  33.         Console.WriteLine("Money for toys: {0}", moneyForToys);
  34.         Console.WriteLine("Money for sweaters: {0}", moneyForSweaters);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement