samedi 21 septembre 2019

Magic 4 Ball not printing all the time

below is my code.

I'm trying to make my code run 100% of the time by the percents I added.

Currently, it runs but sometimes nothing comes up. Any help would be appreciated!!

public class Assessment_Unit_1 {

public static void main(String[] args) {
    boolean good = Math.random() < .13;
    boolean notNow = Math.random() < .37;
    boolean yes = Math.random() < .24;
    boolean never = Math.random() < .26;
    System.out.println("You rolled the Magic 4 Ball:");
    System.out.println("All Signs Say:");
    if (good) {
        System.out.println("Prospects Good");
    }
    else if (notNow) {
        System.out.println("Not now");
    }

    else if (yes) {
        System.out.println("yes");
    }

    else if (never) {
        System.out.println("never");
        }
    }
}   

Aucun commentaire:

Enregistrer un commentaire