Advertisement
damesova

Spring Vacation Trip [Mimi]

Mar 11th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package RealMID_10_03_19;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _01_Task {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int days = Integer.parseInt(scanner.nextLine());
  10.         double budget = Double.parseDouble(scanner.nextLine());
  11.         int people = Integer.parseInt(scanner.nextLine());
  12.         double fuelKM = Double.parseDouble(scanner.nextLine());
  13.         double foodPersonDay = Double.parseDouble(scanner.nextLine());
  14.         double priceNightPerson = Double.parseDouble(scanner.nextLine());
  15.  
  16.         double hotelExp;
  17.  
  18.         if (people > 10) {
  19.             hotelExp = (days *people * priceNightPerson) - ((days * people * priceNightPerson) * 0.25);
  20.         } else {
  21.             hotelExp = days * people * priceNightPerson;
  22.         }
  23.         double foodExp = days * people * foodPersonDay;
  24.         double currentExp = foodExp + hotelExp;
  25.  
  26.         for (int i = 1; i <= days; i++) {
  27.             if (currentExp >= budget) {
  28.                 break;
  29.             }
  30.  
  31.             double km = Double.parseDouble(scanner.nextLine());
  32.             double travelExp = km * fuelKM;
  33.  
  34.             currentExp += travelExp;
  35.  
  36.             if (i % 3 == 0 || i % 5 == 0) {
  37.                 currentExp += (currentExp * 0.4);
  38.             }
  39.  
  40.             if (i % 7 == 0) {
  41.                 double addMoney = currentExp / people;
  42.                 currentExp -= addMoney;
  43.             }
  44.         }
  45.  
  46.  
  47.         if (budget >= currentExp) {
  48.             System.out.printf("You have reached the destination. You have %.2f$ budget left.", budget - currentExp);
  49.         }
  50.         else {
  51.             System.out.printf("Not enough money to continue the trip. You need %.2f$ more.", currentExp - budget);
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement