Advertisement
silvana1303

spring vacantion trip

Jun 17th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int days = int.Parse(Console.ReadLine());
  14.             double budget = double.Parse(Console.ReadLine());
  15.             int groupPeople = int.Parse(Console.ReadLine());
  16.             double fuelPerKm = double.Parse(Console.ReadLine());
  17.             double foodPerDay = double.Parse(Console.ReadLine());
  18.             double roomPerPerson = double.Parse(Console.ReadLine());
  19.  
  20.             double fullExpence = 0;
  21.  
  22.             if (groupPeople > 10)
  23.             {
  24.                 fullExpence = (days * foodPerDay * groupPeople) + ((days * roomPerPerson * groupPeople) * 0.75);
  25.             }
  26.             else
  27.             {
  28.                 fullExpence = (days * foodPerDay * groupPeople) + (days * roomPerPerson * groupPeople);
  29.             }
  30.  
  31.             for (int i = 1; i <= days; i++)
  32.             {
  33.                 double distance = double.Parse(Console.ReadLine());
  34.  
  35.                 fullExpence += distance * fuelPerKm;
  36.  
  37.                 if (i % 3 == 0 || i % 5 == 0)
  38.                 {
  39.                     fullExpence += fullExpence * 0.40;
  40.                 }
  41.                 if (i % 7 == 0)
  42.                 {
  43.                     fullExpence -= fullExpence / groupPeople;
  44.                 }
  45.                 if (budget < fullExpence)
  46.                 {
  47.                     Console.WriteLine($"Not enough money to continue the trip. You need {fullExpence - budget:f2}$ more.");
  48.                     break;
  49.                 }
  50.             }
  51.  
  52.             if (budget >= fullExpence)
  53.             {
  54.                 Console.WriteLine($"You have reached the destination. You have {budget - fullExpence:F2}$ budget left.");
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement