Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class HuxleyCode {
- public static double f(int x, double y) {
- if (x == 5) {
- return 5;
- } else if ((x >= 6) & (x <= 15)) {
- if (x > 12) {
- x = x - 12;
- }
- if (x % 2 == 0) {
- return f(x - 1, y) + (y / 2);
- } else {
- return f(x - 1, y) + (f(x - 1, y) % 7);
- }
- } else if ((x >= 16) | (x <= 4)) {
- if (x > 12) {
- x = x - 12;
- }
- if (x % 2 == 0) {
- return f(x - 1, y) + y;
- } else {
- return f(x - 1, y) + (f(x - 1, y) % 10);
- }
- }
- return 0;
- }
- public static void main(String args[]) {
- Scanner s = new Scanner(System.in);
- int hora = s.nextInt();
- String periodo = s.next();
- double quantSangue = s.nextDouble();
- if ((hora < 1) & (hora > 12) | (quantSangue < 0)) {
- System.out.print("Dados Invalidos.");
- } else {
- if (periodo.equals("pm")) {
- hora = hora + 12;
- }
- double x = f(hora, quantSangue);
- if (x <= 100) {
- System.out.print("A chance de aparecimento de Demogorgon e de "+x+"%");
- } else if (x > 100) {
- System.out.printf("A chance de aparecimento de Demogorgon e de "+x+"%\nOu seja, nao olhe para tras.", x);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement