Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions