Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Spring_vacation_trip
- {
- class Program
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- double budget = double.Parse(Console.ReadLine());
- int numberOfPeople = int.Parse(Console.ReadLine());
- double fuelPerkilometer = double.Parse(Console.ReadLine());
- double foodExpPerPerson = double.Parse(Console.ReadLine());
- double roomPrice = double.Parse(Console.ReadLine());
- bool notEnoughMoney = false;
- double expensesForFood = days * numberOfPeople * foodExpPerPerson;
- double expensesForRooms = days * numberOfPeople * roomPrice;
- if(numberOfPeople>10)
- {
- expensesForRooms *= 0.75;
- }
- double currentExpences = expensesForFood;
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- }
- currentExpences += expensesForRooms;
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- }
- for (int i = 1; i <= days; i++)
- {
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- break;
- }
- double kilometers = double.Parse(Console.ReadLine());
- currentExpences += kilometers * fuelPerkilometer;
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- break;
- }
- if (i%3==0||i%5==0)
- {
- currentExpences *= 1.40;
- }
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- break;
- }
- if (i%7==0)
- {
- currentExpences -= currentExpences / numberOfPeople;
- }
- if (currentExpences > budget)
- {
- notEnoughMoney = true;
- break;
- }
- }
- if(!notEnoughMoney)
- {
- Console.WriteLine($"You have reached the destination. You have {(budget - currentExpences):f2}$ budget left.");
- }
- else
- {
- Console.WriteLine($"Not enough money to continue the trip. You need {(currentExpences - budget):f2}$ more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement