Advertisement
elena1234

SpringVacationTrip

Oct 10th, 2020 (edited)
190
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 SpringVacationTrip
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main()
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double budget = double.Parse(Console.ReadLine());
  11.             int numberOfGroup = int.Parse(Console.ReadLine());
  12.             double priceForFuelPerKm = double.Parse(Console.ReadLine());
  13.             double foodExpensesPerPersonForDay = double.Parse(Console.ReadLine());
  14.             double priceForHotelForOneNightPerPerson = double.Parse(Console.ReadLine());
  15.             double totalFoodExpenses = foodExpensesPerPersonForDay * numberOfGroup * days;
  16.             double totalHotelPrice = days * priceForHotelForOneNightPerPerson*numberOfGroup;
  17.             if (numberOfGroup > 10)
  18.             {
  19.                 totalHotelPrice = totalHotelPrice - (0.25 * totalHotelPrice);
  20.             }
  21.  
  22.             double expenses = totalFoodExpenses + totalHotelPrice;
  23.  
  24.             for (int i = 1; i <= days; i++)
  25.             {
  26.                 double traveledDistanceForCurrentDay = double.Parse(Console.ReadLine());
  27.                 double priceForFuelForCurrentDay =(double) traveledDistanceForCurrentDay * priceForFuelPerKm;
  28.                 expenses = expenses + priceForFuelForCurrentDay;
  29.                 if (i % 3 == 0 || i % 5 == 0)
  30.                 {
  31.                     double additionalExpenses = (double) 0.40 * expenses;
  32.                     expenses += additionalExpenses;
  33.                 }
  34.  
  35.                 if (i % 7 == 0)
  36.                 {                  
  37.                     double reduceExpensesWith = (double) expenses / numberOfGroup;
  38.                     expenses -= reduceExpensesWith;
  39.                 }
  40.  
  41.                 if (expenses > budget)
  42.                 {
  43.                     Console.WriteLine($"Not enough money to continue the trip. You need {expenses-budget:F2}$ more.");
  44.                     return;
  45.                 }
  46.             }
  47.  
  48.             Console.WriteLine($"You have reached the destination. You have {budget-expenses:F2}$ budget left.");
  49.  
  50.          }
  51.  
  52.        }
  53.     }
  54.  
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement