sanyakasarova

02. Family Trip

Oct 23rd, 2021
497
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Loops
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.             int numOfNights = int.Parse(Console.ReadLine());
  11.             double pricePerNight = double.Parse(Console.ReadLine());
  12.             int additionalExpensesPercent = int.Parse(Console.ReadLine());
  13.  
  14.             if (numOfNights > 7)
  15.             {
  16.                 pricePerNight *= 0.95;
  17.             }
  18.  
  19.             double priceForHousing = numOfNights * pricePerNight;
  20.  
  21.             double additionalExpenses = budget * additionalExpensesPercent / 100.0;
  22.  
  23.             double total = priceForHousing + additionalExpenses;
  24.  
  25.             if (total <= budget)
  26.             {
  27.                 Console.WriteLine($"Ivanovi will be left with {budget - total:f2} leva after vacation.");
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine($"{total - budget:f2} leva needed.");
  32.             }
  33.  
  34.         }
  35.     }
  36. }
RAW Paste Data