Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SpringVacationTrip
- {
- class MainClass
- {
- public static void Main()
- {
- int days = int.Parse(Console.ReadLine());
- double budget = double.Parse(Console.ReadLine());
- int numberOfGroup = int.Parse(Console.ReadLine());
- double priceForFuelPerKm = double.Parse(Console.ReadLine());
- double foodExpensesPerPersonForDay = double.Parse(Console.ReadLine());
- double priceForHotelForOneNightPerPerson = double.Parse(Console.ReadLine());
- double totalFoodExpenses = foodExpensesPerPersonForDay * numberOfGroup * days;
- double totalHotelPrice = days * priceForHotelForOneNightPerPerson*numberOfGroup;
- if (numberOfGroup > 10)
- {
- totalHotelPrice = totalHotelPrice - (0.25 * totalHotelPrice);
- }
- double expenses = totalFoodExpenses + totalHotelPrice;
- for (int i = 1; i <= days; i++)
- {
- double traveledDistanceForCurrentDay = double.Parse(Console.ReadLine());
- double priceForFuelForCurrentDay =(double) traveledDistanceForCurrentDay * priceForFuelPerKm;
- expenses = expenses + priceForFuelForCurrentDay;
- if (i % 3 == 0 || i % 5 == 0)
- {
- double additionalExpenses = (double) 0.40 * expenses;
- expenses += additionalExpenses;
- }
- if (i % 7 == 0)
- {
- double reduceExpensesWith = (double) expenses / numberOfGroup;
- expenses -= reduceExpensesWith;
- }
- if (expenses > budget)
- {
- Console.WriteLine($"Not enough money to continue the trip. You need {expenses-budget:F2}$ more.");
- return;
- }
- }
- Console.WriteLine($"You have reached the destination. You have {budget-expenses:F2}$ budget left.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement