Password Project Create a Windows Application that will gather the following inf
ID: 3807559 • Letter: P
Question
Password Project
Create a Windows Application that will gather the following information from a student:
First Name
Last Name
Birthday (may be in the form mm/dd/yyyy or m/d/yyyy)
SS# - in the format ###-##=####
Task 1 – Create a Student class that will receive the data captured by the form and store the following data members (instance variables): first name, last name, birthday, SS#, ID#, username, email address and password. You will use the following rules to find the ID#, username, email address and password. (These tasks will be coded in the class.) You will use separate methods to find the ID#, username, email address and password.
Rule 1 – Use the following rule to create the Student ID#. For each student entered, you will create a random six-digit number that will become the Student ID. (Because the number will be a primary key, the ID# number must be unique. We will assume the Student ID will be unique. I will give extra credit if you code your program to ensure the ID# is unique.)
Rule 2 – Use the following rule to create the user name: The username will be the last name, with no spaces, hyphens or apostrophes and all lower case. This cannot exceed 14 characters. Any part of the last name beyond 14 characters, after spaces and special characters are removed, should be truncated. The adjusted last name will then be followed by the six-digit Student ID to create the complete user name.
Rule 3 – Using the user name, create the student’s Empooria State's email address.
Rule 4 – Using the information below, create the student’s initial password The password will be mmdd of the student’s birthday followed by the last four digits of his/her Social Security number. (e.g. if the birthday is March 4th and the last four digits of the SS# are 2222, the password will be 03042222) If the student did not provide the Registrar’s Office with any birthday information, mmdd will be 9999. If the student does not have a SS#, or did not provide the Registrar’s Office with a SS#, use the last 4 digits of the Student ID.
Task 2 – In the application, create an array of Student(s). Include an Enter Data button. The application will also include a Display Data button which will create a report with the following format. The report should be sorted by last name.
Name User Name Email Address Password
Jones-Smith, Sue jonessmith938221 jonessmith938221@emporiau.edu 12239233
Wilson, Joe wilson348232 wilson345232@emporiau.edu 02177388
Explanation / Answer
This is Student class:
package com.generateStudentID;
import java.util.Random;
public class Student {
String first_name;
String last_name;
String birthday;
String SS;
String ID;
String username;
String email_address;
String password;
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Student(String first_name, String last_name, String birthday,
String sS) {
super();
this.first_name = first_name;
this.last_name = last_name;
this.birthday = birthday;
this.SS = sS;
}
public Student(String username, String email_address, String password) {
super();
this.username = username;
this.email_address = email_address;
this.password = password;
}
public Student(String first_name, String last_name, String birthday,
String sS, String iD, String username, String email_address,
String password) {
super();
this.first_name = first_name;
this.last_name = last_name;
this.birthday = birthday;
this.SS = sS;
this.ID = iD;
this.username = username;
this.email_address = email_address;
this.password = password;
}
public static String createID()
{
// numbers (6), random 0-9
Random r = new Random();
int numbers = 100000 + (int)(r.nextFloat() * 899900);
String val=String.valueOf(numbers);
return val;
}
public static String createUsername(String last_name,String ID)
{
// syntax we would like to generate is DIA123456
String val = last_name;
val += ID;
return val;
}
public static String createEmailAddress(String username)
{
// syntax we would like to generate is xyz688654@emporiau.edu
String val = username;
String append="@emporiau.edu";
val += append;
return val;
}
public static String createPassword(String birthday,String SS)
{
// syntax we would like to generate is 14112222
String val1 = birthday;
String val2 = SS;
String s1=val1.substring(0, 5);
String s2=val2.substring(7, 11);
String s=s1.substring(0, 2) + s1.substring(2 + 1);
String val=s+s2;
return val;
}
public void getDisplay(){
System.out.println("Student Name: "+getLast_name()+","+getFirst_name());
System.out.println("Student Id: "+getID());
System.out.println("Student Username: "+getUsername());
System.out.println("Student Email Address: "+getEmail_address());
System.out.println("Student Password: "+getPassword());
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getSS() {
return SS;
}
public void setSS(String sS) {
SS = sS;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String email_address) {
this.email_address = email_address;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
This is Driver class:
package com.generateStudentID;
import java.util.ArrayList;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<Student> al=new ArrayList<Student>();
Student s=null;
Scanner sc=new Scanner(System.in);
System.out.println(" Student Operations ");
System.out.println("Enter A to Add Student Details");
System.out.println("Enter B to Display Report");
System.out.println("Enter C to Exit");
while(true){
System.out.print("Enter your choice [A,B,& C]: ");
String choice = sc.next();
switch (choice)
{
case "A" :
System.out.print("Enter the Student First Name: ");
String first_name=sc.next();
System.out.print("Enter the Student Last Name: ");
String last_name=sc.next();
System.out.print("Enter the Student Birthday(in the form mm/dd/yyyy): ");
String birthday=sc.next();
System.out.print("Enter the Student SS number(in the format ###-##=####): ");
String sS=sc.next();
String iD=Student.createID();
String username=Student.createUsername(last_name, iD);
String email_address=Student.createEmailAddress(username);
String password=Student.createPassword(birthday, sS);
s=new Student(first_name, last_name, birthday, sS, iD, username, email_address, password);
al.add(s);
break;
case "B" :
for(Student stu:al){
stu.getDisplay();
}
break;
case "C" :
System.out.println("Bye....THANK YOU");
System.exit(0);
break;
default :
System.out.println("Wrong Entry ");
break;
}
}
}
}
Output:
Student Operations
Enter A to Add Student Details
Enter B to Display Report
Enter C to Exit
Enter your choice [A,B & C]: A
Enter the Student First Name: Sue
Enter the Student Last Name: JonesSmith
Enter the Student Birthday(in the form mm/dd/yyyy): 12/23/1999
Enter the Student SS number(in the format ###-##=####): 111-22=9233
Enter your choice [A,B & C ]: A
Enter the Student First Name: Joe
Enter the Student Last Name: Wilson
Enter the Student Birthday(in the form mm/dd/yyyy): 02/17/2000
Enter the Student SS number(in the format ###-##=####): 333-55=7388
Enter your choice [A,B & C]: B
Student Name: JonesSmith,Sue
Student Id: 100470
Student Username: JonesSmith100470
Student Email Address: JonesSmith100470@emporiau.edu
Student Password: 12239233
Student Name: Wilson,Joe
Student Id: 371507
Student Username: Wilson371507
Student Email Address: Wilson371507@emporiau.edu
Student Password: 02177388
Enter your choice [A,B & C]: C
Bye....THANK YOU