borovaneca

Poke Mon

Dec 7th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package Fundamentals.DataTypeAndVariables.Exercises.MoreExercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PokeMon {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int pokePower = Integer.parseInt(scanner.nextLine());
  10.         double originalValue = pokePower;
  11.         int distanceBetweenTargets = Integer.parseInt(scanner.nextLine());
  12.         int exhaustionFactor = Integer.parseInt(scanner.nextLine());
  13.         int pokes = 0;
  14.         double percent = ((originalValue / 2) / originalValue) * 100;
  15.  
  16.         while (pokePower >= distanceBetweenTargets) {
  17.             if (percent == (pokePower / originalValue) * 100 && exhaustionFactor != 0) {
  18.                 pokePower /= exhaustionFactor;
  19.                 continue;
  20.             }
  21.             pokePower -= distanceBetweenTargets;
  22.  
  23.             pokes++;
  24.         }
  25.         System.out.println(pokePower);
  26.         System.out.println(pokes);
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment