Briensither

Untitled

Jun 29th, 2019
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Tech_Module
  6. {
  7.     static void Main()
  8.     {
  9.         int days = int.Parse(Console.ReadLine());
  10.         double budget = double.Parse(Console.ReadLine());
  11.         int people = int.Parse(Console.ReadLine());
  12.         double fuelPerKM = double.Parse(Console.ReadLine());
  13.         double food = double.Parse(Console.ReadLine());
  14.         double room = double.Parse(Console.ReadLine());
  15.  
  16.         if (people > 10)
  17.         {
  18.             room *= 0.75;
  19.         }
  20.         double expenses = days * people * (food + room);
  21.  
  22.         for (int i = 1; i <= days; i++)
  23.         {
  24.             double travelledDistance = double.Parse(Console.ReadLine());
  25.             expenses += travelledDistance * fuelPerKM;
  26.  
  27.             if (i % 3 == 0 || i % 5 == 0)
  28.             {
  29.                 expenses *= 1.4;
  30.             }
  31.             if (i % 7 == 0)
  32.             {
  33.                 expenses -= expenses / people;
  34.             }
  35.  
  36.             if (expenses > budget)
  37.             {
  38.                 Console.WriteLine($"Not enough money to continue the trip. You need {(expenses - budget):f2}$ more.");
  39.                 return;
  40.             }
  41.         }
  42.         Console.WriteLine($"You have reached the destination. You have {(budget - expenses):f2}$ budget left.");
  43.     }
  44. }
Add Comment
Please, Sign In to add comment