Advertisement
silvana1303

disneyland journey

Jun 13th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Exam
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             double moneyNeeded = double.Parse(Console.ReadLine());
  13.             int months = int.Parse(Console.ReadLine());
  14.  
  15.             double sumByFar = 0;
  16.  
  17.             for (int i = 1; i <= months; i++)
  18.             {
  19.                 if (i % 2 == 1 && i != 1)
  20.                 {
  21.                     sumByFar *= 0.84;
  22.                 }
  23.  
  24.                 if (i % 4 == 0)
  25.                 {
  26.                     sumByFar *= 1.25;
  27.                 }
  28.                 sumByFar += moneyNeeded * 0.25;
  29.             }
  30.  
  31.             if (sumByFar >= moneyNeeded)
  32.             {
  33.                 Console.WriteLine($"Bravo! You can go to Disneyland and you will have {sumByFar - moneyNeeded:f2}lv. for souvenirs.");
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine($"Sorry. You need {moneyNeeded - sumByFar:f2}lv. more.");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement