Advertisement
Viniciusfelbs

CUIDADO!Sujeito a ataque de Demogorgon

Oct 3rd, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class HuxleyCode {
  4.  
  5.     public static double f(int x, double y) {
  6.  
  7.         if (x == 5) {
  8.             return 5;
  9.         } else if ((x >= 6) & (x <= 15)) {
  10.             if (x > 12) {
  11.                 x = x - 12;
  12.             }
  13.             if (x % 2 == 0) {
  14.                 return f(x - 1, y) + (y / 2);
  15.             } else {
  16.                 return f(x - 1, y) + (f(x - 1, y) % 7);
  17.  
  18.             }
  19.         } else if ((x >= 16) | (x <= 4)) {
  20.             if (x > 12) {
  21.                 x = x - 12;
  22.             }
  23.             if (x % 2 == 0) {
  24.                 return f(x - 1, y) + y;
  25.             } else {
  26.                 return f(x - 1, y) + (f(x - 1, y) % 10);
  27.  
  28.             }
  29.         }
  30.         return 0;
  31.     }
  32.  
  33.     public static void main(String args[]) {
  34.         Scanner s = new Scanner(System.in);
  35.         int hora = s.nextInt();
  36.         String periodo = s.next();
  37.         double quantSangue = s.nextDouble();
  38.         if ((hora < 1) & (hora > 12) | (quantSangue < 0)) {
  39.             System.out.print("Dados Invalidos.");
  40.         } else {
  41.             if (periodo.equals("pm")) {
  42.                 hora = hora + 12;
  43.             }
  44.             double x = f(hora, quantSangue);
  45.             if (x <= 100) {
  46.                 System.out.print("A chance de aparecimento de Demogorgon e de "+x+"%");
  47.             } else if (x > 100) {
  48.                 System.out.printf("A chance de aparecimento de Demogorgon e de "+x+"%\nOu seja, nao olhe para tras.", x);
  49.  
  50.             }
  51.  
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement