Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class GamesToLegend {
- public static void main(String[] args) {
- Scanner scanIn = new Scanner(System.in);
- System.out.print("What is your winrate? (65% should be written as 0.65) ");
- double winRate = scanIn.nextDouble();
- System.out.print("What rank were you last season? (If Legend, input 0)");
- int numStarsStart = 25-scanIn.nextInt();
- int[] totalGames= new int[10000];
- for(int i = 0;i<totalGames.length;i++){
- int numStars=numStarsStart;
- int winStreak=0;
- int numGames = 0;
- while(numStars < 95){
- if(matchResult(winRate)){
- numStars++;
- winStreak++;
- if(winStreak>3 && numStars < 75) numStars++;
- } else {
- if(numStars>10){
- numStars--;
- }
- winStreak = 0;
- }
- numGames++;
- }
- //System.out.println("You hit legend in " + numGames + " games.");
- totalGames[i]=numGames;
- }
- double avgGames = 0;
- for(int j = 0;j<totalGames.length;j++){
- avgGames+=totalGames[j];
- }
- avgGames/=totalGames.length;
- System.out.println("You reached legend in an average of " + avgGames + " games.");
- }
- public static boolean matchResult(double winRate) {
- Random rand = new Random();
- if(rand.nextDouble()<=winRate){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement