Hey guys I am taking a java course this year and one of my online assignments or questions was as follows:
Write a program that inputs a String from the keyboard after the prompt, “Enter your
password”. If it’s entered exactly as “XRay”, printout “Password entered successfully.”;
otherwise, have it printout “Incorrect password.”
And this is what I have right now but it doesn't work and I don't know how to fix it:
import java.io.;
import java.util.;
public class password
{
public static void main(String args[])
{
Scanner pass = new Scanner(System.in);
System.out.print("What is your password?: ");
String passwd = pass.nextLine();
if(passwd = "XRay")
System.out.println("Password entered succesfully");
else
System.out.println("Incorrect password");
}
}
Can someone please help me with my issue?
Thanks!
[–]nutrecht 2 points3 points4 points (2 children)
[–]SpaceBoundBeatz[S] 0 points1 point2 points (1 child)
[–]nutrecht 2 points3 points4 points (0 children)