Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _01_TheHuntingGames {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- int players = Integer.parseInt(scanner.nextLine());
- double grEnergy = Double.parseDouble(scanner.nextLine());
- double water1per1 = Double.parseDouble(scanner.nextLine());
- double food1per1 = Double.parseDouble(scanner.nextLine());
- double waterGr = players * water1per1 * days;
- double foodGr = players * food1per1 * days;
- for (int i = 1; i <= days; i++) {
- double energy = Double.parseDouble(scanner.nextLine());
- grEnergy -= energy;
- if ((grEnergy) <= 0) {
- System.out.printf("You will run out of energy. You will be left with %.2f food and %.2f water.%n",
- foodGr, waterGr);
- return;
- }
- if (i % 2 == 0) {
- double temp0 = grEnergy * 0.05;
- grEnergy += temp0;
- waterGr -= (waterGr * 0.3);
- }
- if (i % 3 == 0) {
- double temp = foodGr / players;
- foodGr -= temp;
- grEnergy += (grEnergy * 0.1);
- }
- }
- System.out.printf("You are ready for the quest. You will be left with - %.2f energy!", grEnergy);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement