-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtrasmallThistleObject.java
More file actions
84 lines (83 loc) · 3.24 KB
/
Copy pathExtrasmallThistleObject.java
File metadata and controls
84 lines (83 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//Made by Hilarious
//Drop Rate Calculator for Imagine-PS
//Version 3.13
import java.util.Scanner;
import java.util.InputMismatchException;
import java.text.*;
class Main {
public static void main(String[] args) {
String dropChanceS = "";
double dropChanceD = 0;
double dropChanceYo = 0;
int dropRateB = 0, dropRateD = 0;
double dropPotential = 0.0;
DecimalFormat df = new DecimalFormat("#.##");
Scanner scan = new Scanner(System.in);
try {
System.out.println("Enter your current drop rate bonus including double drop rate (Ex: 200% would be 200): ");
dropRateB = scan.nextInt();
System.out.println("Enter current drop rate denominator (Ex: 1/100 would be 100): ");
dropRateD = scan.nextInt();
System.out.println("Enter current drop potential (Ex: 2% would be 2): ");
dropPotential = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Ya dun goofed! Follow the examples and input correct format.");
main(null);
}
if (dropRateD < 100 && dropPotential != 0.0) {
dropChanceS = "Your current drop rate is: " + convertDecimalToFraction((1 / (dropRateD / dropPotential)));
dropChanceYo = (dropRateD / dropPotential);
dropChanceD = dropRateD / (1 + ((double) dropRateB / 100));
} else if (dropRateD < 100 && dropPotential == 0.0) {
dropChanceS = "Your current drop rate is: 1/" + (int) dropRateD;
dropChanceYo = dropRateD;
dropChanceD = dropRateD / (1 + ((double) dropRateB / 100));
} else if (dropRateD >= 100 && dropPotential != 0.0) {
if (dropPotential == 1) {
dropChanceS = "Your current drop rate is: 1/100";
dropChanceD = dropRateD / (1 + ((double) dropRateB / 100));
} else {
dropChanceS = "Your current drop rate is: " + convertDecimalToFraction((1 / (100 / dropPotential)));
dropChanceYo = (100 / dropPotential);
dropChanceD = dropRateD / (1 + ((double) dropRateB / 100));
}
} else if (dropRateD >= 100 && dropPotential == 0.0) {
dropChanceS = "Your current drop rate is: 1/" + (int) dropRateD;
dropChanceYo = (int) dropRateD;
dropChanceD = dropRateD / (1 + ((double) dropRateB / 100));
}
if (dropChanceYo > dropChanceD || dropChanceYo == 0) {
System.out.println("Your current drop rate is: 1/" + (int) dropChanceD);
double chance = 1 / dropChanceD;
for (int i = 10; i <= 100; i += 10) {
double chanceP = 100 - (Math.pow(1 - chance, i) * 100);
System.out.println("You have a " + df.format(chanceP) + "% chance to get this drop in the next " + i + " kills.");
}
} else {
System.out.println(dropChanceS);
double chance = 1 / dropChanceYo;
for (int i = 10; i <= 100; i += 10) {
double chanceP = 100 - (Math.pow(1 - chance, i) * 100);
System.out.println("You have a " + df.format(chanceP) + "% chance to get this drop in the next " + i + " kills.");
}
}
main(null);
}
static private String convertDecimalToFraction(double x) {
if (x < 0) {
return "-" + convertDecimalToFraction(-x);
}
double tolerance = 1.0E-6;
double h1 = 1, h2 = 0, k1 = 0, k2 = 1, b = x;
do {
double a = Math.floor(b), aux = h1;
h1 = a * h1 + h2;
h2 = aux;
aux = k1;
k1 = a * k1 + k2;
k2 = aux;
b = 1 / (b - a);
} while (Math.abs(x - h1 / k1) > x * tolerance);
return 1 + "/" + Math.round((int) Math.ceil(k1 / h1));
}
}