SHARE
TWEET

Untitled

a guest Mar 18th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Spring_vacation_trip
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double budget = double.Parse(Console.ReadLine());
  11.             int numberOfPeople = int.Parse(Console.ReadLine());
  12.             double fuelPerkilometer = double.Parse(Console.ReadLine());
  13.             double foodExpPerPerson = double.Parse(Console.ReadLine());
  14.             double roomPrice = double.Parse(Console.ReadLine());
  15.  
  16.             bool notEnoughMoney = false;
  17.             double expensesForFood = days * numberOfPeople * foodExpPerPerson;
  18.             double expensesForRooms = days * numberOfPeople * roomPrice;
  19.             if(numberOfPeople>10)
  20.             {
  21.                 expensesForRooms *= 0.75;
  22.             }
  23.             double currentExpences = expensesForFood;
  24.             if (currentExpences > budget)
  25.             {
  26.                 notEnoughMoney = true;
  27.             }
  28.             currentExpences += expensesForRooms;
  29.             if (currentExpences > budget)
  30.             {
  31.                 notEnoughMoney = true;
  32.             }
  33.  
  34.             for (int i = 1; i <= days; i++)
  35.             {
  36.                 if (currentExpences > budget)
  37.                 {
  38.                     notEnoughMoney = true;
  39.                     break;
  40.                 }
  41.                 double kilometers = double.Parse(Console.ReadLine());
  42.                 currentExpences += kilometers * fuelPerkilometer;
  43.                 if (currentExpences > budget)
  44.                 {
  45.                     notEnoughMoney = true;
  46.                     break;
  47.                 }
  48.                 if (i%3==0||i%5==0)
  49.                 {
  50.                     currentExpences *= 1.40;
  51.                 }
  52.                 if (currentExpences > budget)
  53.                 {
  54.                     notEnoughMoney = true;
  55.                     break;
  56.                 }
  57.                 if (i%7==0)
  58.                 {
  59.                     currentExpences -= currentExpences / numberOfPeople;
  60.                 }
  61.                 if (currentExpences > budget)
  62.                 {
  63.                     notEnoughMoney = true;
  64.                     break;
  65.                 }
  66.             }
  67.             if(!notEnoughMoney)
  68.             {
  69.                 Console.WriteLine($"You have reached the destination. You have {(budget - currentExpences):f2}$ budget left.");
  70.             }
  71.             else
  72.             {
  73.                 Console.WriteLine($"Not enough money to continue the trip. You need {(currentExpences - budget):f2}$ more.");
  74.             }
  75.            
  76.         }
  77.     }
  78. }
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