Ask Question

write a java program using a do while loop to prompt the user to enter a password. The user should be prompted to enter the password until the correct password "pals" is entered.

+2
Answers (1)
  1. 9 June, 13:12
    0
    We can import Scanner from Java. utils. Scanner to pull in text entered in the console.

    public static void main (String[] args) {

    Scanner sc = new Scanner (System. in);

    String password = "";

    do {

    System. out. print ("Enter your password: ");

    password = sc. nextLine ();

    if (! password. equals ("pals") {

    System. out. println (/nIncorrect Password. Try again.");

    }

    } while (! password. equals ("pals");
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “write a java program using a do while loop to prompt the user to enter a password. The user should be prompted to enter the password until ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers