SHARE
TWEET

Untitled

a guest Apr 14th, 2019 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class first {
  6.     public static void main(String[] args) throws IOException {
  7.         BufferedReader reader =
  8.                 new BufferedReader(
  9.                         new InputStreamReader(
  10.                                 System.in
  11.                         )
  12.                 );
  13.  
  14.         int days = Integer.parseInt(reader.readLine());
  15.         int countOfPlayers = Integer.parseInt(reader.readLine());
  16.         double energy = Double.parseDouble(reader.readLine());
  17.         double water = Double.parseDouble(reader.readLine());
  18.         double food = Double.parseDouble(reader.readLine());
  19.         double waterForAll = water * countOfPlayers * days;
  20.         double foodForAll = food * countOfPlayers * days;
  21.  
  22.         for (int i = 1; i <= days ; i++) {
  23.             if (energy <= 0) {
  24.                 System.out.println(String.format("You will run out of energy. You will be left with %.2f food and %.2f water.", foodForAll, waterForAll));
  25.                 return;
  26.             }
  27.             double removeEnergy = Double.parseDouble(reader.readLine());
  28.             energy -= removeEnergy;
  29.                 if (i % 2 == 0) {
  30.                     energy += energy * 0.05;
  31.                     waterForAll -= waterForAll * 0.3;
  32.                 }if (i % 3 == 0) {
  33.                     energy += energy * 0.1;
  34.                     foodForAll -= foodForAll / countOfPlayers;
  35.                 }
  36.         }
  37.         System.out.println(String.format("You are ready for the quest. You will be left with - %.2f energy!", energy));
  38.     }
  39. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top