The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a JAVA program to enter Employee data, including social security number and salary, into an array. (The maximum number of employees is 100, but your program should also work for any number of employees less than 100.) Your program should use two exception classes called SSNLengthException for when the social security number entered (SSN) is not exactly nine characters and SSNCharacterException for when any character in the social security number is not a digit. (The SSN is to be entered with just the numbers and no dashes or spaces.) When an exception is thrown, the user is reminded of what she or he entered, told why it is inappropriate, and asked to reenter the data. After all data has been entered, your program will output the records for all employees, with an annotation stating whether the employeeA????1s salary is above or below average. You will also need to define the classes Employee, SSNLengthException, and SSNCharacterException. The class Employee will be a derived class of the class Person available on the K: drive. Among other things, the class Employee should have input and output methods, as well as constructors, accessor methods, and mutator methods. Every employee object will record the employeeA????1s name, salary, and social security number (plus any other data you need or think are appropriate).
This is what I have so far:
public class Person
{
private String name;
 Â
public Person()
{
name = "No name yet";
}
 Â
public Person(String initialName)
{
name = initialName;
}
 Â
public void setName(String newName)
{
name = newName;
}
 Â
public String getName()
{
return name;
}
 Â
public void writeOutput()
{
System.out.println("Name: " + name);
}
 Â
public boolean hasSameName(Person otherPerson)
{
return this.name.equalsIgnoreCase(otherPerson.name);
}
}
public class Employee
{
private String firstName;
private String lastName;
private String socialSecurityNumber;
// constructor
public Employee(String first, String last, String ssn)
{
firstName = first;
lastName = last;
socialSecurityNumber = ssn;
}
// set first name
public void setFirstName(String first)
{
firstName = first;
}
// return first name
public String getFirstName()
{
return firstName;
}
// set last name
public void setLastName(String last)
{
lastName = last;
}
// return last name
public String getLastName()
{
return lastName;
}
 Â
//set social security number
public void setSocialSecurityNumber(String number)
{
socialSecurityNumber = number; // should validate
}
// return social security number
public String getSocialSecurityNumber()
{
return socialSecurityNumber;
}
// return String representation of Employee object
public String toString()
{
return getFirstName() + " " + getLastName() +
"\nsocial security number: " + getSocialSecurityNumber();
}
} // end class Employee
public class SSNCharacterException extends Exception
{
public SSNCharacterException()
{
super("Inappropriate Character in SSN:Non Digit Character Found");
}
public SSNCharacterException(String msg)
{
super(msg);
}
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll