desislava_topuzakova

10. Poke Mon

Sep 24th, 2021
975
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Test;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PokeMon_10 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int power = Integer.parseInt(scanner.nextLine());
  9.         int distance = Integer.parseInt(scanner.nextLine());
  10.         int exhaustionFactor = Integer.parseInt(scanner.nextLine());
  11.  
  12.         //stop: power < distance
  13.         //continue: power >= distance
  14.         int count = 0; //брой на poke-ве
  15.         int firstTimePower = power; //първоначалната стойност на силата преди poke-ване
  16.         while (power >= distance) {
  17.             power -= distance; //1 poke
  18.             count++;
  19.             //проверка дали текущия power == половината от първоначалния
  20.             if (power == firstTimePower * 0.5 && exhaustionFactor != 0) {
  21.                     power = power / exhaustionFactor; //power /= exhaustionFactor;
  22.             }
  23.         }
  24.  
  25.         System.out.println(power);
  26.         System.out.println(count);
  27.     }
  28. }
  29.  
RAW Paste Data