dimanche 22 octobre 2017

factoring if/else statements in a program that keeps score

i'm trying to factor my code that prints out a message that depends on the value i assign to a variable. i want to factor the "your score is " + score part but i don't know how to because the score depends on the value i assign it, which is dependent on the total score. see below:

int score;
    if (total >= 50) {
    score = 100;
         System.out.println("Your score is " + score);

         } else if (total >= 0) {
            score = 0;
            System.out.println("Your score is " + score);
            }

Aucun commentaire:

Enregistrer un commentaire