EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

 

Password Validation system: A system requires a user to enter a password. The user gets 3 attempts to enter the correct password

 

Write a java program that asks the user to enter a password. If they enter the wrong password,they get another chance. If they fail 3 times, the program should display “Access Denied” and terminate

 

import java.util.*;

 

class ASC

{

public static void main(String args[])

{

Scanner s=new Scanner(System.in);

 

String correct=”abc123@”;

 

int attempt=0;

 

while(attempt<3)

{

System.out.println(“Enter the password”);

String a=s.nextLine();

 

if(a.equals(correct))

{

System.out.println(“Okay you can proceed..”);

break;

}

else

{

attempt++;

if(attempt==3)

{

System.out.println(“Access Denied”);

}

else

{

System.out.println(“Wrong password”);

}

}}

}

}

Password validation in java

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer