Advertisement
milenaki

Disneyland_Journey

Feb 25th, 2020
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Disneyland_Journey
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             decimal jurneyCost = decimal.Parse(Console.ReadLine());
  10.           int numMonths = int.Parse(Console.ReadLine());
  11.             decimal monthSum = jurneyCost * 25/100;
  12.            decimal totalSum = 0;
  13.             decimal spentOdd = 0;
  14.             decimal bonusFourhtMonth = 0;
  15.      
  16.             for (int i = 1; i <= numMonths; i++)
  17.             {
  18.                 spentOdd = 0;
  19.                 bonusFourhtMonth = 0;
  20.                if(i%4 == 0)
  21.                 {
  22.                     bonusFourhtMonth += totalSum * 25/100;
  23.                     totalSum += monthSum +bonusFourhtMonth;
  24.                 }
  25.                else if(i%2 != 0 && i!=1)
  26.                 {
  27.                     spentOdd -= totalSum * 16/100 ;
  28.                     totalSum += (monthSum+spentOdd);
  29.                 }
  30.                 else
  31.                 {
  32.                     totalSum += monthSum;
  33.                 }
  34.             }
  35.             decimal result = Math.Abs(jurneyCost - totalSum);
  36.             if (totalSum >= jurneyCost)
  37.             {
  38.                 Console.WriteLine($"Bravo! You can go to Disneyland and you will have {(result):F2}lv. for souvenirs.");
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine($"Sorry. You need {(result):f2}lv. more.");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement