Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java. training
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qazi Zain
Java. training
Commits
d7901b64
Commit
d7901b64
authored
Oct 17, 2024
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new task are added
parent
d043845c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
Password.java
src/JavaTrainingTask/Question4a/Password.java
+42
-0
main.java
src/JavaTrainingTask/Question4a/main.java
+9
-0
No files found.
src/JavaTrainingTask/Question4a/Password.java
0 → 100644
View file @
d7901b64
package
JavaTrainingTask
.
Question4a
;
import
java.util.Scanner
;
public
class
Password
{
int
pin
;
Scanner
obj
;
Password
()
{
System
.
out
.
println
(
"Object is created!"
);
pin
=
0
;
obj
=
new
Scanner
(
System
.
in
);
}
void
checkPassword
()
{
boolean
value
=
true
;
int
count
=
0
;
final
int
correctPassword
=
1234
;
while
(
value
&&
count
<
3
)
{
System
.
out
.
println
(
"Enter the password:"
);
pin
=
obj
.
nextInt
();
if
(
pin
==
correctPassword
)
{
System
.
out
.
println
(
"Access granted!"
);
value
=
false
;
}
else
{
count
++;
System
.
out
.
println
(
"Incorrect password. Try again."
);
if
(
count
==
3
)
{
System
.
out
.
println
(
"Maximum attempts reached. Access denied."
);
}
}
}
}}
\ No newline at end of file
src/JavaTrainingTask/Question4a/main.java
0 → 100644
View file @
d7901b64
package
JavaTrainingTask
.
Question4a
;
public
class
main
{
public
static
void
main
(
String
[]
args
)
{
Password
obj
=
new
Password
();
obj
.
checkPassword
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment