SHARE
TWEET

Untitled

a guest Feb 18th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace GiftboxCoverage
  2. {
  3.     using System;
  4.     class GiftboxCoverageStart
  5.     {
  6.         static void Main()
  7.         {
  8.             int days = int.Parse(Console.ReadLine());
  9.             double budget = double.Parse(Console.ReadLine());
  10.             int people = int.Parse(Console.ReadLine());
  11.             double fuelPrice = double.Parse(Console.ReadLine());
  12.             double foodExpencesPerOne = double.Parse(Console.ReadLine());
  13.             double nightExpencesPerOne = double.Parse(Console.ReadLine());
  14.  
  15.             double foodExpences = days * people * foodExpencesPerOne;
  16.             double hotelExpences = days * people * nightExpencesPerOne;
  17.  
  18.             if (people > 10)
  19.             {
  20.                 hotelExpences *= 0.75;
  21.             }
  22.  
  23.             double totalExpences = foodExpences + hotelExpences;
  24.  
  25.             for (int i = 1; i <= days; i++)
  26.             {
  27.                 double kilometers = double.Parse(Console.ReadLine());
  28.                 totalExpences += kilometers * fuelPrice;
  29.  
  30.                 if (totalExpences > budget)
  31.                 {
  32.                     Console.WriteLine($"Not enough money to continue the trip. You need {totalExpences - budget:f2}$ more.");
  33.                     return;
  34.                 }
  35.                 if (i % 3 == 0 || i % 5 == 0)
  36.                 {
  37.                     totalExpences *= 1.4;
  38.                 }
  39.                 if (totalExpences > budget)
  40.                 {
  41.                     Console.WriteLine($"Not enough money to continue the trip. You need {totalExpences - budget:f2}$ more.");
  42.                     return;
  43.                 }
  44.                 if (i % 7 == 0)
  45.                 {
  46.                     totalExpences -= totalExpences / people;
  47.                 }
  48.                
  49.             }
  50.  
  51.             Console.WriteLine($"You have reached the destination. You have {budget - totalExpences:F2}$ budget left.");
  52.         }
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top