Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _1grupa_SpringVacationTrip
- {
- class Program
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- double budget = double.Parse(Console.ReadLine());
- int people = int.Parse(Console.ReadLine());
- double fuelPrice = double.Parse(Console.ReadLine());
- double foodPrice = double.Parse(Console.ReadLine());
- double roomPrice = double.Parse(Console.ReadLine());
- double hotelExpenses = roomPrice * people * days; //предварително изчисляваме цената за разходите
- double foodExpenses = foodPrice * people * days; //на хотела и на храната
- double totalExpenses = 0;
- if (people > 10)
- {
- hotelExpenses = 0.75 * hotelExpenses;
- }
- totalExpenses = hotelExpenses + foodExpenses; //сумираме преди да сме влезли в цикъла
- for (int i = 1; i <= days; i++)
- {
- if (totalExpenses > budget) //в началото на деня проверяваме дали не сме надхвърлили бюджета (заради предварителното изчисляване на горните разходи)
- {
- break;
- }
- double travelExpenses = fuelPrice * double.Parse(Console.ReadLine()); //изчисляваме цената за гориво за настоящия ден
- totalExpenses += travelExpenses; //добавяме само цената за гориво
- if (i % 3 == 0 || i % 5 == 0) //на всеки 3-ти и 5-ти ден увеличаваме разходите с 40%
- {
- totalExpenses *= 1.4;
- }
- if (i % 7 == 0) //на всеки 7-ми ден редуцираме цената
- {
- totalExpenses -= totalExpenses / people;
- }
- }
- if (totalExpenses > budget)
- {
- Console.WriteLine($"Not enough money to continue the trip. You need {totalExpenses - budget:f2}$ more.");
- }
- else if (totalExpenses <= budget)
- {
- Console.WriteLine($"You have reached the destination. You have {budget - totalExpenses:f2}$ budget left.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment