Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Threading;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- double budget = double.Parse(Console.ReadLine());
- int groupPeople = int.Parse(Console.ReadLine());
- double fuelPerKm = double.Parse(Console.ReadLine());
- double foodPerDay = double.Parse(Console.ReadLine());
- double roomPerPerson = double.Parse(Console.ReadLine());
- double fullExpence = 0;
- if (groupPeople > 10)
- {
- fullExpence = (days * foodPerDay * groupPeople) + ((days * roomPerPerson * groupPeople) * 0.75);
- }
- else
- {
- fullExpence = (days * foodPerDay * groupPeople) + (days * roomPerPerson * groupPeople);
- }
- for (int i = 1; i <= days; i++)
- {
- double distance = double.Parse(Console.ReadLine());
- fullExpence += distance * fuelPerKm;
- if (i % 3 == 0 || i % 5 == 0)
- {
- fullExpence += fullExpence * 0.40;
- }
- if (i % 7 == 0)
- {
- fullExpence -= fullExpence / groupPeople;
- }
- if (budget < fullExpence)
- {
- Console.WriteLine($"Not enough money to continue the trip. You need {fullExpence - budget:f2}$ more.");
- break;
- }
- }
- if (budget >= fullExpence)
- {
- Console.WriteLine($"You have reached the destination. You have {budget - fullExpence:F2}$ budget left.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement