vendredi 10 avril 2020

Wondering why the condition for the else statement continues to be the output. Using String Variable

import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
String name = inp.nextLine();

if(inp.equals("Chen")){
  System.out.print("teacher");
}

else{
  System.out.print("student");
}

}
}

Continuously keep getting "student" no matter how much I play with the If portion. Not missing capitalization of the name Chen and even tried to store Chen in a variable and have that as part of the condition and still end with the else.

Aucun commentaire:

Enregistrer un commentaire