Advertisement
mastersan12

Spring Vacation

Mar 11th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Spring_Vacation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double budget = double.Parse(Console.ReadLine());
  11.             int groupOfPeople = int.Parse(Console.ReadLine());
  12.             double fuelPerKM = double.Parse(Console.ReadLine());
  13.             double food = double.Parse(Console.ReadLine());
  14.             double roomPrice = double.Parse(Console.ReadLine());
  15.  
  16.  
  17.  
  18.            
  19.             double foodExpenses = food * groupOfPeople * days;
  20.             double hotelExpenses = roomPrice * groupOfPeople * days;
  21.             if (groupOfPeople > 10)
  22.             {
  23.                 hotelExpenses = hotelExpenses - hotelExpenses * 0.25;
  24.             }
  25.             double totalExpenses = foodExpenses + hotelExpenses;
  26.  
  27.             for (int currentDay = 1; currentDay <= days; currentDay++)
  28.             {
  29.                 double travelledKM = double.Parse(Console.ReadLine());
  30.                 totalExpenses = totalExpenses + (travelledKM * fuelPerKM);
  31.  
  32.                 if (currentDay % 3 == 0 || currentDay % 5==0)
  33.                 {
  34.                     totalExpenses = totalExpenses + totalExpenses * 0.4;
  35.                 }
  36.                 else if (currentDay % 7 == 0)
  37.                 {
  38.                     double earnMoney = totalExpenses / groupOfPeople;
  39.                     totalExpenses -= earnMoney;
  40.                 }
  41.                 if (totalExpenses > budget)
  42.                 {
  43.                     Console.WriteLine($"Not enough money to continue the trip. You need {totalExpenses - budget:f2}$ more.");
  44.                     return;
  45.                 }
  46.             }
  47.  
  48.  
  49.             if (budget >= totalExpenses)
  50.             {
  51.                 Console.WriteLine($"You have reached the destination. You have {budget - totalExpenses:f2}$ budget left.");
  52.             }
  53.             else
  54.             {
  55.                 Console.WriteLine($"Not enough money to continue the trip. You need {totalExpenses - budget:f2}$ more.");
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement