mercredi 11 novembre 2015

Else If commands (Android Studio)

I have a text field in my project. Next, i want to be able to type in a command into that text field and some code will run.

So i'm thinking it's a 'else if' command. Something like this

System.out.println("Enter all your grades (A,B,C,D,F) and enter 'done' if you are done entering your grades."); 
while (!doneInput) {        
    String grade = in.next();

    if(grade == "A"){
        totalGradePoints += 4;
        numClasses++;
    }

(This code was taken from Java if, else-if, else statement)

But i'm not sure how to do it.

Aucun commentaire:

Enregistrer un commentaire