vendredi 13 septembre 2019

How to check if the input given by the user is Y or N

to summarise it give me any idea or solution on how I could fix it.

I tried what is given in the code below.

System.out.print("Want to continue Shopping or end your shopping spree and want the bill for your shopping (answer in Y or N)");
            String end = sc.next();
            if(end =="Y")
                System.out.println("hello");

I expect the output hello in the above code, but the actual results are nothing the program just ends.

Aucun commentaire:

Enregistrer un commentaire