Advertisement
desislava_topuzakova

10. Poke Mon

May 27th, 2022
788
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DataTypesVariables;
  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()); //N
  9.         int distance = Integer.parseInt(scanner.nextLine()); //M
  10.         int exhaustionFactor = Integer.parseInt(scanner.nextLine()); //Y
  11.  
  12.         //повтаряме: poke
  13.         //stop: power < distance
  14.         //continue: power >= distance
  15.  
  16.         int count = 0; //брой на poke
  17.         int startPower = power; //първоначалната си сила
  18.         while (power >= distance) {
  19.             power -= distance;
  20.             //POKE
  21.             count++;
  22.  
  23.             //проверка дали съм на половината от първоначалните си сили
  24.             if (power == startPower * 0.5) {
  25.                 if (exhaustionFactor > 0) {
  26.                     power = power / exhaustionFactor;
  27.                     //power /= exhaustionFactor;
  28.                 }
  29.             }
  30.         }
  31.  
  32.         System.out.println(power);
  33.         System.out.println(count);
  34.     }
  35. }
Advertisement
RAW Paste Data Copied
Advertisement