Advertisement
aggressiveviking

02.FamilyTrip

Feb 26th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.FamilyTrip
  4. {
  5.     class FamilyTrip
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.             int nightCnt = int.Parse(Console.ReadLine());
  11.             double nightPrice = double.Parse(Console.ReadLine());
  12.             int percent = int.Parse(Console.ReadLine());
  13.  
  14.             if (nightCnt > 7)
  15.             {
  16.                 nightPrice = nightPrice * 0.95;
  17.             }
  18.  
  19.             double totalNightPrice = nightCnt * nightPrice;
  20.             double additionalCosts = budget * (percent / 100.0);
  21.  
  22.             double totalPrice = totalNightPrice + additionalCosts;
  23.            
  24.             if (totalPrice > budget)
  25.             {
  26.                 double moneyNeed = totalPrice - budget;
  27.                 Console.WriteLine($"{moneyNeed:F2} leva needed.");
  28.             }
  29.             else
  30.             {
  31.                 double moneyLeft = budget - totalPrice;
  32.                 Console.WriteLine($"Ivanovi will be left with {moneyLeft:F2} leva after vacation.");
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement