Advertisement
sylviapsh

Toys

Dec 27th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. class Toys
  3. {
  4.   static void Main()
  5.   {
  6.     //Telerik Academy
  7.     //You are given a certain amount of money (stotinki). There are 3 types of toys you could buy. You should buy the maximum amount of one type of toy possible.
  8.  
  9.     string input = Console.ReadLine();
  10.     string[] inputSplitted = input.Split(' ');
  11.  
  12.     decimal[] numbers = Array.ConvertAll<string, decimal>(inputSplitted, decimal.Parse);
  13.  
  14.     decimal stotinkiS = (numbers[0]),
  15.             priceToy1 = (numbers[1]),
  16.             priceToy2 = (numbers[2]),
  17.             priceToy3 = (numbers[3]);
  18.  
  19.     int maxToys1 = (int)(stotinkiS / priceToy1),
  20.         maxToys2 = (int)(stotinkiS / priceToy2),
  21.         maxToys3 = (int)(stotinkiS / priceToy3),
  22.         resultToy = maxToys1;
  23.  
  24.     if (maxToys2 > maxToys1 && maxToys2 > maxToys3)
  25.     {
  26.       resultToy = maxToys2;
  27.     }
  28.     else if (maxToys3 > maxToys2 && maxToys3 > maxToys1)
  29.     {
  30.       resultToy = maxToys3;
  31.     }
  32.  
  33.     Console.WriteLine(resultToy);
  34.  
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement