[рд╣рд▓] The Better Music Producer - C# Task

  

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

After a young rock band wins a music contest, they receive offers from two famous producers. And now they must choose the better one.

The first one offers the young musicians to record an album and distribute it in North America, South America, and Europe. The band makes a research to find out┬аhow many albums┬аcan be┬аsold in each continent, as well as the┬аprice for the music┬аalbum in local currency.

According to the contract, the┬аproducer takes 35%┬аfrom all profits. The band must pay┬а20% taxes┬аon the rest of the income.

The second offer includes a world tour with тАЬNтАЭ (number of) concerts. Each concert makes the same amount of profit. If the total income from all concerts is┬аmore than┬а100,000 lv┬аthe producer┬аkeeps 15%.

Your task is to write a program to┬аcalculate┬аwhich offer is better. YouтАЩll be given some┬аnumbers.

For the┬аfirst┬аoffer - the┬аnumber of albums┬аsold in┬аeach┬аcontinent and the┬аprice┬аfor a┬аsingle album┬аin each continent.

For the second offer тАУ┬аthe number of concerts┬аand the┬аprofit from a single concert┬а(it is the same for all concerts). You must convert all currencies in┬аlevas. Assume that:

  • 1 euro is 1.94lv.
  • 1 dollar is 1.72lv.
  • 332.74 pesos are 1lv.

Find the profit┬аfrom all albums,┬аsubtract┬аthe┬аproducerтАЩs share┬аand after that┬аsubtract┬аtaxes.┬аFinally you must┬аfind┬аwhich of the offers is┬аmore profitable. Print your results on the console.

Input

The input data should be read from the console. It will consist of exactly 8 lines:

  1. The number of albums sold in Europe
  2. The price of an album in euro
  3. The number of albums sold in North America
  4. The price of an album in dollars
  5. The number of albums sold in South America
  6. Price of an album in pesos
  7. The number of concerts during a tour
  8. Profit from a single concert in euro

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

Output

The output should be printed on the console.

  • If the total profit from all album is more than from all concerts print on the console:
    • тАЬLetтАЩs record some songs! TheyтАЩll bring us {incomes from albums}lv.тАЭ
  • If it is equal to or the profit from the concerts is greater:
    • тАЬOn the road again! WeтАЩll see the world and earn {profit from concerts}lv.тАЭ
  • All incomes must be rounded to two digits after the decimal point.

Constraints

  • The prices for different continents and incomes from concert will be a valid floating-point numbers in range [0тАж7.9 x 1028]
  • The count of albums and concerts will be a valid integers in range [0тАж 10000]
  • Allowed working time for your program: 0.25 seconds.
  • Allowed memory: 16 MB.

Examples

better music producer - C# task

better music producer - C# task - 1

better music producer - C# task - comments

1 рдЙрддреНрддрд░
3

Interesting task! Here is my solution:

using System;
 
class BetterMusicProducer18October2015
{
    static void Main()
    {
        decimal numberAlbumsEu = decimal.Parse(Console.ReadLine());//The number of albums sold in Europe
        decimal priceEu = decimal.Parse(Console.ReadLine());//The price of an album in euro
 
        decimal numberAlbumsNorthAmerica = decimal.Parse(Console.ReadLine());//The number of albums sold in North America
        decimal priceDollars = decimal.Parse(Console.ReadLine());//The price of an album in dollars
 
        decimal numberAlbumsSouthAmerica = decimal.Parse(Console.ReadLine());//The number of albums sold in South America
        decimal pricePessos = decimal.Parse(Console.ReadLine());//Price of an album in pesos
 
        decimal numberConcerts = decimal.Parse(Console.ReadLine());//The number of concerts during a tour
        decimal profitFromOneConcert = decimal.Parse(Console.ReadLine());//Profit from a single concert in euro
 
        decimal profitEu = ((numberAlbumsEu * priceEu) * 1.94m);
        decimal profitNorthA = ((numberAlbumsNorthAmerica * priceDollars) * 1.72m);
        decimal profitSouthA = ((numberAlbumsSouthAmerica * pricePessos) * 0.0030053495221494m);
 
        decimal profitOverall = profitEu + profitNorthA + profitSouthA;
        decimal producerProcent = (profitOverall * 0.35m);
        decimal taxes = ((profitOverall - producerProcent) * 0.2m);
        decimal profitNet = profitOverall - (producerProcent + taxes);
 
        decimal profitConcerts = ((numberConcerts * profitFromOneConcert) * 1.94m);//The price of the concert is in euro - that is why we multiply by 1.94 - to get leva
         
        if (profitConcerts > 100.000m)
        {
            profitConcerts = (profitConcerts - (profitConcerts * 0.15m));
        }
 
        if (profitNet > profitConcerts)
        {
            Console.WriteLine("Let's record some songs! They'll bring us {0:f2}lv.", profitNet);
        }
        else if (profitConcerts >= profitNet)
        {
            Console.WriteLine("On the road again! We'll see the world and earn {0:f2}lv.", profitConcerts);
        }
    }
}
рд╢реЗрдпрд░ рдХрд░рдирд╛: