[рд╣рд▓] Impress the girlfriend - C# Task

  

4
рд╡рд┐рд╖рдп рдкреНрд░рд╛рд░рдВрднрдХрд░реНрддрд╛

Spiro is a big CS GO fan. He's been saving money for months to buy the new Counter Strike game. However, he has┬аfive options┬аto buy the game from.

The first one┬аis a shady Russian site selling games in┬аrubles┬а(Russian currency).┬аAnother option┬аis an American site selling games in┬аdollars┬а(American currency). Spiro's┬аthird option┬аis the official site of the game - selling games in┬аeuros┬а(European Union currency).┬аThe final 2 options┬аare Bulgarian sites┬аB┬аand┬аM.┬аBoth of them sell in┬аleva┬а(Bulgarian currency).

B┬аoffers a very┬аspecial deal - 2 copies┬аof the game for┬аthe price of one. M┬аsells games for┬аnormal prices.┬аSpiro is very bad with math and can't calculate the game prices in leva. But he wants to impress his girlfriend by showing her he bought the most expensive game.

Assume that Spiro has a girlfriend,┬аall games are identical, 100 rubles┬аare┬а3.5 leva, 1 dollar┬аis┬а1.5 leva, 1 euro┬аis┬а1.95 leva

and if Spiro┬аbuys 2 special games┬аfrom B and he always┬аsell one┬аof them for exactly┬аhalf of the money┬аhe paid for both.

Your task is to write a program that calculates┬аthe most expensive game.

Input

The input data should be read from the console. It consists of five input values, each at a separate line:

  • The number┬аr┬атАУ amount of┬аrubles┬аSpiro has to pay for the game at the Russian site.
  • The number┬аd┬атАУ amount of┬аdollars┬аSpiro has to pay for the game at the American site.
  • The number┬аe┬атАУ amount of┬аeuro┬аSpiro has to pay for the game at the official site.
  • The number┬аb┬атАУ amount of┬аleva┬аSpiro has to pay for the special offer at B.
  • The number┬аm┬атАУ amount of┬аleva┬аSpiro has to pay for the game at M's site.

The input data will always be valid and in the format described. There is no need to check it explicitly.

Output

  • The output data must be printed on the console. On the only output line you must print┬аthe most expensive game price rounded up to the next integer number.

Constraints

  • The numbers┬аr, d, e, b, m┬аare integer numbers in range [0... 4,294,967,295].
  • Allowed working time for your program: 0.1 seconds.
  • Allowed memory: 16 MB.

Examples

impress the girlfriend c sharp task example1

impress the girlfriend c sharp task example 2

impress the girlfriend c sharp task example 3

impress the girlfriend c sharp task example 4

2 рдЙрддреНрддрд░
3

Here's my solution to your task:

using System;
 
class ImpressTheGirlfriend
{
    static void Main()
    {
        decimal rubles = decimal.Parse(Console.ReadLine());
        decimal dollars = decimal.Parse(Console.ReadLine());
        decimal euro = decimal.Parse(Console.ReadLine());
        decimal bgOne = decimal.Parse(Console.ReadLine());
        decimal bgTwo = decimal.Parse(Console.ReadLine());
         
        decimal rublesLv = rubles * 0.035m;
        decimal dollarsLv = dollars * 1.5m;
        decimal euroLv = euro * 1.95m;
        decimal bgOneConv = bgOne / 2;
 
        if (rublesLv > dollarsLv && rublesLv > euroLv && rublesLv > bgOneConv && rublesLv > bgTwo)
        {
            Console.WriteLine("{0:F2}", Math.Ceiling(rublesLv));
        }
 
        else if (dollarsLv > rublesLv && dollarsLv > euroLv && dollarsLv > bgOneConv && dollarsLv > bgTwo)
        {
            Console.WriteLine("{0:F2}", Math.Ceiling(dollarsLv));
        }
 
        else if (euroLv > rublesLv && euroLv > dollarsLv && euroLv > bgOneConv && euroLv > bgTwo)
        {
            Console.WriteLine("{0:F2}", Math.Ceiling(euroLv));
        }
 
        else if (bgOneConv > rublesLv && bgOneConv > dollarsLv && bgOneConv > euroLv && bgOneConv > bgTwo)
        {
            Console.WriteLine("{0:F2}", Math.Ceiling(bgOneConv));
        }
 
        else if (bgTwo > rublesLv && bgTwo > dollarsLv && bgTwo > euroLv && bgTwo > bgOneConv)
        {
            Console.WriteLine("{0:F2}", Math.Ceiling(bgTwo));
        }
    }
}
1

The same solution like eiorgert's one - but at the end with array (using array's method array.Max();) - it is more evelegant one - without ifs + again with Math.Ceiling and the placeholder {0:f2}:

using System;
using System.Linq;
 
class ImpressTheGirlfriend
{
    static void Main()
    {
        decimal rubles = decimal.Parse(Console.ReadLine());
        decimal dollars = decimal.Parse(Console.ReadLine());
        decimal euro = decimal.Parse(Console.ReadLine());
        decimal bgOne = decimal.Parse(Console.ReadLine());
        decimal bgTwo = decimal.Parse(Console.ReadLine());
 
        decimal rublesLv = rubles * 0.035m;
        decimal dollarsLv = dollars * 1.5m;
        decimal euroLv = euro * 1.95m;
        decimal bgOneConv = bgOne / 2;
 
        decimal[] array = new[] { rublesLv, dollarsLv, euroLv, bgOneConv, bgTwo };
 
        Console.WriteLine("{0:f2}", Math.Ceiling(array.Max()));
    }
}
рд╢реЗрдпрд░ рдХрд░рдирд╛: