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

Find the slope of the line that contains the points named. P(1, 2), Q(3, 4) -1 1 2
An employee is paid a gross yearly salary of $57,000.00. How much does this employee earn each month? A. $4,795.00 B. $4,780.00 C. $4,750.00 D. $5,105.00
What are drug control strategies?
Which of the following is an extremely reactive family of elements? a. noble gases c. carbon family b. halogens d. metalloids
Which of the following BEST describes the process of developing and maintaining a strong family relationship? a. avoid conflict as much as possible, avoid comm
What is75% of 562.80
What are carbohydrates converted into? A. Fructose B. Sucrose C. Lactose D. Glucose
wat is the meaning of BMI?
What should you do if a test tube breaks while you are conducting a laboratory experiment?
The primary nerve which transmits the sensations of smell is the _____ nerve. olfary olfactory optic auditory