samedi 12 septembre 2020

I cannot get the second line (else if with less than 60) to output at all

I've; changed the operator from < to <=, changed the statement from 'else if' to 'if' and nothing will get it to output. I'm a very new prgrammer with only a few weeks of class under my belt and could really use some help on what I'm missing here. Thank you in advance for any help you can provide. I've provided the instructions and my code.

**Instructions Extend the template code to analyze a student's test score and give them advice, as follows:

(1) Add code to read a test score into the score variable.

Then evaluate the score entered, and use a decision statement to display some output. When the score entered is 80 or above, output: Doing well Otherwise, output: Study more End your output with a newline.

(2) Extend the program to add one more check.

When the score entered is below 60, output: and go to office hours for help on the next line, ending again with a newline.

MY CODE***************************************

// Author: Chelsie McFall

import java.util.Scanner;

public class ScoreInterpreter {

   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);   
      int score = 0;

      score = scnr.nextInt();

      System.out.println("Enter your test score:");
    
      if (score >= 80) {                           
          System.out.println("Doing well");
      }
      else if (score < 60) {                        
          System.out.println("and go to office hours for help"); 
      }

      System.out.println("Study more");
   }

}

Aucun commentaire:

Enregistrer un commentaire