mardi 28 novembre 2017

If statement while using scanner java

I'm trying to read the line given by the user and take it and print out the right thing. Right now, when I enter Julian, it doesn't print anything.

import java.util.Scanner;

public class fantasyFootball {

    public static void main(String[ ] args) {
        Scanner reader = new Scanner(System.in); 
        System.out.println("Enter a name: ");
        String n = reader.toString();

        if("Julian".equals(n)){ 
            System.out.println("Win and Win: You go to the Playoffs");
            System.out.println("Lose and Win: ");
            System.out.println("Lose and Win: ");
            System.out.println("Lose and Lose: ");
        }
        reader.close();
    } 
}

Aucun commentaire:

Enregistrer un commentaire