Question: Hi, I was asked to create a Java programthat takes 2 words as input from the keyboard, that should represent a password adn the same

Hi, I was asked to create a Java programthat takes 2 words as input from the keyboard, that should represent a password adn the same password again. (Just like prompting a user to enter a password and entering it again when creating an account on a website.) Basically, if both passwords match, then it should notify the user it has a registered account, otherwise they will be notified of a typo in the password they try to create. Below is a program I have working in progress. Can you look at it and show the modifications with comments? Thank you.

import java.util.Scanner; //Needed for the Scanner class

public class YourLastNameValidPassword {

public static void main(String[] args) { //to hold the user's input String password; //to hold the user's input String open = null; //A Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); //Prompt the user to enter the password. System.out.println("Please enter your password: "); boolean password1 = keyboard.nextLine(); //Determine if the user entered the right password. if (password1 == open) { System.out.print("Please re-enter your password: "); password1 = keyboard.nextLine(); if(password1 = open != null) { System.out.println("Sorry, there is a typo in your password."); } else { System.out.println("You are now registered as a new user."); } } else { System.out.println("Sorry, there is a typo in your password."); }

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!