Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int days = Integer.parseInt(sc.nextLine());
- int players = Integer.parseInt(sc.nextLine());
- double energy = Double.parseDouble(sc.nextLine());
- double waterPerDay = Double.parseDouble(sc.nextLine());
- double foodPerDay = Double.parseDouble(sc.nextLine());
- double energyLoss = 0.0;
- double totalWater = days * players * waterPerDay;
- double totalFood = days * players * foodPerDay;
- boolean isEnergy = true;
- for (int i = 1; i <= days; i++) {
- energyLoss = Double.parseDouble(sc.nextLine());
- energy -= energyLoss;
- if (energy <= 0) {
- isEnergy = false;
- break;
- }
- if(i % 2 == 0) {
- energy *= 1.05;
- totalWater *= 0.7;
- }
- if (i % 3 == 0) {
- totalFood -= totalFood / players;
- energy *= 1.1;
- }
- }
- if (isEnergy) {
- System.out.printf("You are ready for the quest. You will be left with - %.2f energy!", energy );
- } else {
- System.out.printf("You will run out of energy. You will be left with %.2f food and %.2f water.", totalFood, totalWater );
- }
- }
- }
Add Comment
Please, Sign In to add comment