Advertisement
damesova

The Hunting Games [Mimi]

Apr 15th, 2019
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class _01_TheHuntingGames {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scanner.nextLine());
  8.         int players = Integer.parseInt(scanner.nextLine());
  9.         double grEnergy = Double.parseDouble(scanner.nextLine());
  10.         double water1per1 = Double.parseDouble(scanner.nextLine());
  11.         double food1per1 = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double waterGr = players * water1per1 * days;
  14.         double foodGr = players * food1per1 * days;
  15.  
  16.         for (int i = 1; i <= days; i++) {
  17.             double energy = Double.parseDouble(scanner.nextLine());
  18.             grEnergy -= energy;
  19.  
  20.             if ((grEnergy) <= 0) {
  21.                 System.out.printf("You will run out of energy. You will be left with %.2f food and %.2f water.%n",
  22.                         foodGr, waterGr);
  23.                 return;
  24.             }
  25.  
  26.             if (i % 2 == 0) {
  27.                 double temp0 = grEnergy * 0.05;
  28.                 grEnergy += temp0;
  29.                 waterGr -= (waterGr * 0.3);
  30.             }
  31.  
  32.             if (i % 3 == 0) {
  33.                 double temp = foodGr / players;
  34.                 foodGr -= temp;
  35.                 grEnergy += (grEnergy * 0.1);
  36.             }
  37.         }
  38.  
  39.         System.out.printf("You are ready for the quest. You will be left with - %.2f energy!", grEnergy);
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement