tiaharris3893 tiaharris3893
  • 07-08-2019
  • Computers and Technology
contestada

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.

Respuesta :

cdw2014
cdw2014 cdw2014
  • 08-08-2019
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");
Answer Link

Otras preguntas

Every general type of plant or animal can only reproduce a like organism. TRUE OR FALSE.
How many lines of symmetry does a square of possible answers: 3,5,6,12
While some parents consider themselves to be their child’s friend, many parents believe that a parent should behave as a parent and not as a friend. In today’
Read the sentence.Ray and I like bird watching, but he enjoys it more than _____.Choose the correct pronoun to complete the sentence. me I we us
Claude Bernard first recognized _____. A. separate fluids outside and inside the cell B. plant stomata opening and closing to maintain homeostasis C. feedba
What are the next three terms of the geometric sequence 32, -16, 8, …? a.2, 1, 1/2c.-8, 16, -32b.4, 2, 1d.-4, 2, -1
what are civil liberties
Find the remainder of (x4 – 2) ÷ (x + 1)
What act was completely repealed after the boycotts and violence against tax collectors? A -Sugar and Molasses Act B -Stamp Act C -Townshend Acts D -Intolerable
I need help on this question!!!