0% found this document useful (0 votes)
4 views

CS111-Group Project Report Form (4)

The document is a project report for a Password Services Program submitted by a group of students at Taibah University as part of their CS111 course. It includes a declaration of originality, an overview of the program's functionality, and the source code for generating and checking password strength. The report also contains screenshots demonstrating the program's outputs and user interactions.

Uploaded by

faal5532
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CS111-Group Project Report Form (4)

The document is a project report for a Password Services Program submitted by a group of students at Taibah University as part of their CS111 course. It includes a declaration of originality, an overview of the program's functionality, and the source code for generating and checking password strength. The report also contains screenshots demonstrating the program's outputs and user interactions.

Uploaded by

faal5532
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Kingdom Of Saudi Arabia ‫وزارة‬

Ministry Of Education ‫التعليم‬


Taibah University ‫جامعة طيبة‬
‫المملكة العربية‬
‫السعودي ة‬
College Of Computer Science ‫كلية‬ ‫علوم وهندسة الحاسب‬
‫اآللي‬and Engineering

Password Services Program


A Project Report Submitted to Fulfill the Requirements of CS111

By Group (G):

‫محمد احمد بلحمر‬ )TUID:4502653(

( ‫عبدالله محمد العوفي‬ :TUID(4502956(

‫ فيصل عادل الفريد ي‬:TUID(4503232

‫فيصل رشيد العياض ي‬ :TUID(4500492(

Supervised By

Dr. Mohammad M. Alsuraihi


30 November, 2024

ASSIGNMENT DECLARATION FORM


By submitting this work and signing this document, we declare that:
1. This assignment is our own original work.
2. No part of this work has been copied from any other source or person except where
explicitly stated otherwise by reference or acknowledgment.
3. No part of this work has been previously submitted for assessment at this or any other
institution.
4. We may be subject to student discipline processes in the event of an act of
5. academic misconduct by us including an act of plagiarism or cheating.

Course Code Course Title


CS111 Programming 1

Student Name Student ID Signature


1 ‫محمد احمد بلحمر‬ 4502653

2 ‫عبدالله محمد العوفي‬ 4502956

3 ‫فيصل عادل الفريد ي‬ 4503232

4 ‫فيصل رشيد العياض ي‬ 4500492

Date of signature

For instructor:

1
CLO Assigned marks Awarded marks

2.2 2

3.1 3

4.1 1

4.2 1

Total 7

The program’s code text as copied from NetBeans:


package passwordservices;

import java.util.Scanner;

public class passwordservices {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);
int choice;

System.out.println("Welcome to our password services project");

d
o
{
System.out.println("\nTo generate passwords, please enter 1.");
System.out.println("To check the strength of your password, please enter
2.");
System.out.println("To generate passwords and check their strengths,
please enter 3.");

2
System.out.println("To exit the program, please enter 0.");
System.out.print("Enter your choice: ");

while (!input.hasNextInt()) {
System.out.println("Invalid input. Please enter a valid number.");
input.next();
}
choice = input.nextInt();

switch (choice)
{ case 1:
System.out.print("Enter the password
length: "); int length1 = input.nextInt();
if (length1 > 0) {

String[] passwords = generatePasswords(length1);


printPasswordsSimple(passwords);
} else {
System.out.println("Password length should be a positive integer.");
}
break;

case 2:
System.out.print("Enter your
password: "); String password =
input.next(); int score =
checkStrength(password);
printStrengthMessage(score); break;

case 3:

3
System.out.print("Enter the password
length: "); int length2 = input.nextInt();
if (length2 > 0) {
String[] passwords = generatePasswords(length2);
printPasswordsWithStrength(passwords);
} else {
System.out.println("Password length should be a positive integer.");
}
break;

case 0:
System.out.println("Exiting the program. Goodbye!");
break;

default:
System.out.println("Invalid choice. Please try again.");
break;
}
} while (choice != 0);

input.close();
}

// Generate 3 random passwords of specified length


public static String[] generatePasswords(int length) {
String[] passwords = new String[3];
String characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456
789! @#$%^&*()";

for (int i = 0; i < 3; i++) {

4
StringBuilder password = new
StringBuilder(); for (int j = 0; j < length; j+
+) {
int randomIndex = (int) (Math.random() * characters.length());
password.append(characters.charAt(randomIndex));
}
passwords[i] = password.toString();
}
return passwords;
}

// Print passwords without strength (option 1)


public static void printPasswordsSimple(String[]
passwords) { System.out.println("Here are a few
options:"); for (String password : passwords) {
System.out.println(password);
}
}

// Print passwords with their strength (option 3)


public static void printPasswordsWithStrength(String[]
passwords) { System.out.println("Here are a few options:");
for (String password : passwords) { int score =
checkStrength(password); System.out.print(password + "
"); printStrengthMessageInline(score);
}
}

// Check password strength and return a score


public static int checkStrength(String password)
{ int score = 0;

5
if (password.matches(".*[A-Z].*")) score++; // Uppercase
letter if (password.matches(".*[a-z].*")) score++; //
Lowercase letter if (password.matches(".*\\d.*")) score+
+; // Number
if (password.matches(".*[!@#$%^&*()].*")) score++; // Special
character if (password.length() >= 8) score++; // Length >= 8
return score;
}

// Print password strength message (option 2)


public static void printStrengthMessage(int
score) { switch (score) { case 5:
System.out.println("This is a very good
password!"); break; case 4:
System.out.println("This is a good password, but you can still do
better."); break;

case 3:
System.out.println("This is a medium password, try making it
better."); break; case 2: case 1:
System.out.println("This is a weak password, you should find a new
one!"); break; default:
System.out.println("This password has no strength.");
break;
}
}

// Print strength message inline (used in option 3)


public static void printStrengthMessageInline(int
score) { switch (score) { case 5:

6
System.out.println("This is a very good
password!"); break; case 4:
System.out.println("This is a good password, but you can still do
better."); break; case 3:
System.out.println("This is a medium password, try making it
better."); break; case 2: case 1:
System.out.println("This is a weak password, you should find a new
one!"); break; default:
System.out.println("This password has no strength.");
break;
}
}
}

7
The outputs screenshots as copied from NetBeans:
Welcome to our password services project To generate passwords, please enter 1.
To check the strength of your password, please enter 2. To generate passwords and
check their strengths, please enter 3. To exit the program, please enter 0. Enter
your choice: 1
Enter the password length: 8 Here are a few options: 73X0r7AE WVEuPlex
UBOEA^0R To generate passwords, please enter 1. To check the strength of your
password, please enter 2. To generate passwords and check their strengths, please
enter 3. To exit the program, please enter 0. Enter your choice: 2 Enter your
password: 8 This is a weak password, you should find a new one! To generate
passwords, please enter 1. To check the strength of your password, please enter 2.
To generate passwords and check their strengths, please enter 3. To exit the
program, please enter 0. Enter your choice: 3 Enter the password length: 8 Here
are a few options: 5Z$tJSxg This is a very good password! sPpzkVKG This is a
medium password, try making it better. ctbBiFZ@ This is a good password, but
you can still do better. To generate passwords, please enter 1. To check the strength
of your password, please enter 2. To generate passwords and check their strengths,
please enter 3. To exit the program, please enter 0. Enter your choice: 0 Exiting the
program. Goodbye! BUILD SUCCESSFUL (total time: 55 seconds)

You might also like