Ask Question
Today, 14:33

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.

+4
Answers (1)
  1. Today, 15:13
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers