lundi 2 novembre 2020

Basic Java boolean/string with if statments [closed]

I am in a beginner java class. I am having a tough time understanding the code. Within the code, a true/false statement has to be asked, I used a string to do this. Then further down I the code, there are if statements related to the true/false user input. Do I have to convert the true/false to boolean for it to be read elsewhere in the code? I the program executes but will never read the false statement, it will only print the true results.

Any help would be appreciated.

    // ask for students name
    System.out.print("Are you a PA resident (enter true or false)? ");
    String PAresident = kybd.next();
    return PAresident;
    }

for else if statement here is the false statement I need it to read from the above question

//Non-PA residents taking less than 12 credits pay $482 per credit else if (false && credits < 12) tuition = 482 * credits;

I've read a bunch of helpful suggestions on this site but honestly I get lost in most of it.

Aucun commentaire:

Enregistrer un commentaire