Advertisement
Valantina

FamilyTrip/Exam

Jul 9th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P02_FamilyTrip
  4. {
  5.     class P02_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.             if (totalPrice > budget)
  24.             {
  25.                 double moneyNeed = totalPrice - budget;
  26.                 Console.WriteLine($"{moneyNeed:F2} leva needed.");
  27.             }
  28.             else
  29.             {
  30.                 double moneyLeft = budget - totalPrice;
  31.                 Console.WriteLine($"Ivanovi will be left with {moneyLeft:F2} leva after vacation.");
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement