mercredi 19 juin 2019

Array card count/ Histogram

I am currently making a program where one of the choices in where the user enters their rank ( highest card) and how many suits they have so hypothetically if one has a rank as 5 and 4 suits, they have twenty cards(1-5 cards). For one of the options the user has the decision to run the program 100,000 times and they are asked how many cards do they want dealt . Ex. User has a rank of 5 and 4 suits, the user wants to be dealt 3 cards, so the program out of 100,000 terms will calculate what they got for each result from 3 to 15( the possible sums you can get from picking cards 1 to 5 3 times). Its a histogram but without the visual aspect of it and it just shows the results, this is the whole program (https://github.com/alexxei4/cardcount). And specifically this is what im stuck on. All help and feedback is appreciated please and thank you

if(Choice ==3){
            System.out.println("How many cards would like to be drawn?");
            main.setcardask2(sc.nextInt());
            int[] maxcard = new int[(main.getcardask2() * main.getranks())+ 1];
            for (int i = 0; i < 100_000; i++) {
                int random = (int) (Math.random() * (highestthousand - lowestthousand + 1));
                maxcard[random]++;
            }
                for (int i = main.getcardask2(); i < 16; i++) {
                    System.out.println(i + ": " + maxcard[i]);

                }
         }




Aucun commentaire:

Enregistrer un commentaire