Question

JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and...

JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and position. You will also define the type of company. Is it an engineering firm, a supermarket, or a call center? Once the application has been completed, I should be able to perform a query for any piece of information associated with each employee.   For instance, if I search for employees who make over $50,000, all of the employees whose salaries are greater than $50,000 should print to the screen. If I ask for employees whose last name starts with a 'C' , all employees with the last name beginning with a 'C' should print to the screen. I should be able to repeat the query as many times as I wish. When I am done, I should be given the option to quit the program.  

These are the guidelines you must follow:

1. The application must contain at least 20 employees.

2. Some of the employees can have the same first name, but they should all have different last names. Some of the names can start with the same letter, but try using at least 10 different letters.  

3. There must be at least 4 salary ranges, i.e. 20-40K, 40-60k, etc... Also, each employee should have a specific salary. $45,555, $79,898, and so on.

4. The employee contact information must include the following: employee id, first name, last name, m/f, start date, address, telephone number, social security number, and date of birth (which should return an age).  

5. Each employee should be classified by their position in the company, i.e. President, Manager, secretary, engineer, programmer, scientist, etc. Model their positions on the company itself.  

6. There should be a final option for me to see all of the information related to a specific employee. If I choose this option, please ensure that all of the employee's information is printed to the screen in a professional looking format. You are free to design this on your own.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

package ClassProg;

import java.util.Scanner;

// Defines a class MyDate

class MyDate

{

// Instance variable to store date

int day;

int month;

int year;

// Default constructor to initialize instance variables

MyDate()

{

day = month = year = 0;

}// End of default constructor

// Parameterized constructor to assign parameter values to instance variables

MyDate(int d, int m, int y)

{

day = d;

month = m;

year = y;

}// End of parameterized constructor

// Overrides toString() method to return date information

public String toString()

{

return day + "/" + month + "/" + year;

}// End of method

}// End of class MyDate

// Driver class EmployeeQuery definition

public class EmployeeQuery

{

// Instance variable to store employee data

String employeeID, firstName, lastName;

char gender;

MyDate startDate, DOB;

String address, telephoneNumber, socialSecurityNumber, position;

double salary;

// Creates a Scanner class object

static Scanner sc = new Scanner(System.in);

// Default constructor to initialize instance variables

EmployeeQuery()

{

employeeID = firstName = lastName = address = telephoneNumber =

socialSecurityNumber = position = "";

gender = ' ';

startDate = DOB = null;

salary = 0.0;

}// End of default constructor

// Parameterized constructor to assign parameter values to instance variables

EmployeeQuery(String eid, String fn, String ln, String add, String tn, String ssn, String po,

char ge, MyDate sd, MyDate dob, double sal)

{

employeeID = eid;

firstName = fn;

lastName = ln;

address = add;

telephoneNumber = tn;

socialSecurityNumber = ssn;

position = po;

gender = ge;

startDate = sd;

DOB = dob;

salary = sal;

}// End of parameterized constructor

// Overrides toString() method to return employee information

public String toString()

{

return "\n Employee ID: " + employeeID + "\n Social Security Number: " + socialSecurityNumber +

"\n First Name: " + firstName + "\n Last Name: " + lastName + "\n Address: " + address +

"\n Telephone Number: " + telephoneNumber + "\n Position: " + position +

"\n Gender: " + gender + "\n Start Date: " + startDate + "\n DOB: " + DOB +

"\n Salary $" + salary;

}// End of method

// Method to display employees salary more than the given parameter salary

void searchSalary(EmployeeQuery empQ[], double salary)

{

// Loops till number of employees

for(int x = 0; x < empQ.length; x++)

{

// Checks if current employee salary is greater than the parameter salary

if(empQ[x].salary > salary)

// Displays employee information

System.out.println(empQ[x]);

}// End of for loop

}// End of method

// Method to display employees last name starts with given parameter character

void startsWith(EmployeeQuery empQ[], char lastName)

{

// Loops till number of employees

for(int x = 0; x < empQ.length; x++)

{

// Checks if current employee last name first character is equals to the parameter character

if(empQ[x].lastName.charAt(0) == lastName)

// Displays employee information

System.out.println(empQ[x]);

}// End of for loop

}// End of method

// Method to display menu, accepts user choice and return user choice

int menu()

{

// Displays menu

System.out.print("\n 1 Find out the employees earns more than given salary.");

System.out.print("\n 2 Find out the employees last name satarts with given character.");

System.out.print("\n 3 Quit.");

// Accepts user choice

System.out.print("\n Enter your choice: ");

int ch = sc.nextInt();

// Returns user choice

return ch;

}// End of method

// main method definition

public static void main(String ss[])

{

// To store the salary entered by the user

double sal = 0;

// To store the character entered by the user

char startsWith = ' ';

// Creates an array of objects of the class EmployeeQuery of size 20

EmployeeQuery empQ[] = new EmployeeQuery[20];

// Creates an array for first name and assigns data to it

String firstName[] = {"Pyari", "Sasmita", "Tanvi", "Manvi", "Bishnu", "Priya", "Amiya", "Anil",

"Sunil", "Ram", "Sita", "Manvi", "Rita", "Mita", "Nitu", "Roja", "Rinku",

"Binod", "Pyari", "Tanvi"};

// Creates an array for last name and assigns data to it

String lastName[] = {"Sahu", "Panda", "Sahu", "Panda", "Prasad", "Swain", "Swain", "Sharma",

"Padhy", "Kar", "Muduli", "Panda", "Sharma", "Sahu", "Kar", "Muduli", "Ratha",

"Ratha", "Mohan", "Padhy"};

// Creates an array for employee id and assigns data to it

String employeeID[] = {"111", "112", "113", "114", "115", "116", "117", "118",

"119", "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", "130"};

// Creates an array for address and assigns data to it

String address[] = {"BAM", "BBSR", "RKL", "GAT", "BBSR", "ABM", "RTS", "CCT",

"CCR", "BAM", "BBSR", "RKL", "BAL", "BBT", "BBSR", "RKL", "BAM", "BAL", "SAT", "BET"};

// Creates an array for telephone number and assigns data to it

String telephoneNumber[] = {"12345699811", "2245879123", "11356789456", "2356894587",

"32644456987", "2456987123", "2245699987", "2365696669", "3366545569", "12366654899",

"4445656598", "6669899998", "7789822569", "3334565895", "35644569874", "1223568945",

"3365658585", "5558987845", "2654789123", "3326548995"};

// Creates an array for SSN and assigns data to it

String socialSecurityNumber[] = {"111333", "112456", "222113", "894114", "654115", "999116",

"122417", "112118", "155619", "115520", "415221", "991722", "881238", "781294",

"184525", "789126", "321127", "781128", "569129", "559130"};

// Creates an array for position and assigns data to it

String position[] = {"President", "secretary", "President", "Manager", "engineer", "secretary",

"programmer", "scientist", "Manager", "President", "programmer", "engineer", "scientist",

"secretary", "engineer", "Manager", "President", "programmer", "secretary", "President"};

// Creates an array for grade and assigns data to it

char gender[] = {'M', 'F', 'F', 'F', 'M', 'F', 'M', 'M', 'M', 'M', 'F', 'F', 'F', 'F', 'F',

'F', 'M', 'M', 'M', 'F'};

// Creates an array of objects of class MyDate for starting date and

// Creates MyDate object using parameterized constructor and assigns the objects to it

MyDate startDate[] = {new MyDate(27,03,1976), new MyDate(12,02,1999), new MyDate(03,01,2000),

new MyDate(20,11,1911), new MyDate(15,12,2004), new MyDate(10,02,2015),

new MyDate(04,03,2008), new MyDate(19,12,2004), new MyDate(14,11,1988),

new MyDate(11,02,2004), new MyDate(25,01,2007), new MyDate(17,10,2006),

new MyDate(16,12,1979), new MyDate(16,04,2001), new MyDate(27,04,2004),

new MyDate(16,11,2007), new MyDate(17,03,1999), new MyDate(20,06,2001),

new MyDate(28,04,2017), new MyDate(27,02,2018)};

// Creates an array of objects of class MyDate for date of birth and

// Creates MyDate object using parameterized constructor and assigns the objects to it

MyDate DOB[] = {new MyDate(15,03,2011), new MyDate(10,04,2001), new MyDate(13,01,2008),

new MyDate(22,11,1911), new MyDate(11,12,2004), new MyDate(14,03,2015),

new MyDate(14,02,2007), new MyDate(25,02,2004), new MyDate(18,13,2007),

new MyDate(17,05,2014), new MyDate(15,01,2002), new MyDate(19,03,2006),

new MyDate(25,07,2004), new MyDate(18,06,2010), new MyDate(20,01,2001),

new MyDate(28,01,2007), new MyDate(27,02,1988), new MyDate(25,01,2004),

new MyDate(29,02,2012), new MyDate(17,06,2016)};

// Creates an array for salary and assigns data to it

double empSalary[] = {89000, 80000, 79000, 79000, 56000, 77000, 33000, 29000, 45000, 39000,

49000, 72000, 59000, 55000, 32000, 67000, 37000, 8900067, 69000, 32000};

// Loops till length of the EmployeeQuery array of object

for(int x = 0; x < empQ.length; x++)

// Creates an object using parameterized constructor and assigns it to x index position

empQ[x] = new EmployeeQuery(employeeID[x], firstName[x], lastName[x],

address[x], telephoneNumber[x], socialSecurityNumber[x], position[x],

gender[x], startDate[x], DOB[x], empSalary[x]);

// Loops till user choice is not 3

do

{

// Calls the method to accept user choice

// According to the returned user choice calls the appropriate method  

switch(empQ[0].menu())

{

case 1:

// Accepts salary

System.out.print("\n Enter the salary to search: ");

sal = sc.nextDouble();

empQ[0].searchSalary(empQ, sal);

break;

case 2:

// Accepts a character

System.out.print("\n Enter the starting character of last name to search: ");

startsWith = Character.toUpperCase(sc.next().charAt(0));

empQ[0].startsWith(empQ, startsWith);

break;

case 3:

System.exit(0);

default:

System.out.print("\n Invalid Choice!");

}// End of switch case

}while(true);// End of do - while loop

}// End of main method

}// End of driver class EmployeeQuery

Sample Output:


1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 2

Enter the starting character of last name to search: S

Employee ID: 111
Social Security Number: 111333
First Name: Pyari
Last Name: Sahu
Address: BAM
Telephone Number: 12345699811
Position: President
Gender: M
Start Date: 27/3/1976
DOB: 15/3/2011
Salary $89000.0

Employee ID: 113
Social Security Number: 222113
First Name: Tanvi
Last Name: Sahu
Address: RKL
Telephone Number: 11356789456
Position: President
Gender: F
Start Date: 3/1/2000
DOB: 13/1/2008
Salary $79000.0

Employee ID: 116
Social Security Number: 999116
First Name: Priya
Last Name: Swain
Address: ABM
Telephone Number: 2456987123
Position: secretary
Gender: F
Start Date: 10/2/2015
DOB: 14/3/2015
Salary $77000.0

Employee ID: 117
Social Security Number: 122417
First Name: Amiya
Last Name: Swain
Address: RTS
Telephone Number: 2245699987
Position: programmer
Gender: M
Start Date: 4/3/2008
DOB: 14/2/2007
Salary $33000.0

Employee ID: 118
Social Security Number: 112118
First Name: Anil
Last Name: Sharma
Address: CCT
Telephone Number: 2365696669
Position: scientist
Gender: M
Start Date: 19/12/2004
DOB: 25/2/2004
Salary $29000.0

Employee ID: 123
Social Security Number: 881238
First Name: Rita
Last Name: Sharma
Address: BAL
Telephone Number: 7789822569
Position: scientist
Gender: F
Start Date: 16/12/1979
DOB: 25/7/2004
Salary $59000.0

Employee ID: 124
Social Security Number: 781294
First Name: Mita
Last Name: Sahu
Address: BBT
Telephone Number: 3334565895
Position: secretary
Gender: F
Start Date: 16/4/2001
DOB: 18/6/2010
Salary $55000.0

1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 1

Enter the salary to search: 68000

Employee ID: 111
Social Security Number: 111333
First Name: Pyari
Last Name: Sahu
Address: BAM
Telephone Number: 12345699811
Position: President
Gender: M
Start Date: 27/3/1976
DOB: 15/3/2011
Salary $89000.0

Employee ID: 112
Social Security Number: 112456
First Name: Sasmita
Last Name: Panda
Address: BBSR
Telephone Number: 2245879123
Position: secretary
Gender: F
Start Date: 12/2/1999
DOB: 10/4/2001
Salary $80000.0

Employee ID: 113
Social Security Number: 222113
First Name: Tanvi
Last Name: Sahu
Address: RKL
Telephone Number: 11356789456
Position: President
Gender: F
Start Date: 3/1/2000
DOB: 13/1/2008
Salary $79000.0

Employee ID: 114
Social Security Number: 894114
First Name: Manvi
Last Name: Panda
Address: GAT
Telephone Number: 2356894587
Position: Manager
Gender: F
Start Date: 20/11/1911
DOB: 22/11/1911
Salary $79000.0

Employee ID: 116
Social Security Number: 999116
First Name: Priya
Last Name: Swain
Address: ABM
Telephone Number: 2456987123
Position: secretary
Gender: F
Start Date: 10/2/2015
DOB: 14/3/2015
Salary $77000.0

Employee ID: 122
Social Security Number: 991722
First Name: Manvi
Last Name: Panda
Address: RKL
Telephone Number: 6669899998
Position: engineer
Gender: F
Start Date: 17/10/2006
DOB: 19/3/2006
Salary $72000.0

Employee ID: 128
Social Security Number: 781128
First Name: Binod
Last Name: Ratha
Address: BAL
Telephone Number: 5558987845
Position: programmer
Gender: M
Start Date: 20/6/2001
DOB: 25/1/2004
Salary $8900067.0

Employee ID: 129
Social Security Number: 569129
First Name: Pyari
Last Name: Mohan
Address: SAT
Telephone Number: 2654789123
Position: secretary
Gender: M
Start Date: 28/4/2017
DOB: 29/2/2012
Salary $69000.0

1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 9

Invalid Choice!
1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 1

Enter the salary to search: 78000

Employee ID: 111
Social Security Number: 111333
First Name: Pyari
Last Name: Sahu
Address: BAM
Telephone Number: 12345699811
Position: President
Gender: M
Start Date: 27/3/1976
DOB: 15/3/2011
Salary $89000.0

Employee ID: 112
Social Security Number: 112456
First Name: Sasmita
Last Name: Panda
Address: BBSR
Telephone Number: 2245879123
Position: secretary
Gender: F
Start Date: 12/2/1999
DOB: 10/4/2001
Salary $80000.0

Employee ID: 113
Social Security Number: 222113
First Name: Tanvi
Last Name: Sahu
Address: RKL
Telephone Number: 11356789456
Position: President
Gender: F
Start Date: 3/1/2000
DOB: 13/1/2008
Salary $79000.0

Employee ID: 114
Social Security Number: 894114
First Name: Manvi
Last Name: Panda
Address: GAT
Telephone Number: 2356894587
Position: Manager
Gender: F
Start Date: 20/11/1911
DOB: 22/11/1911
Salary $79000.0

Employee ID: 128
Social Security Number: 781128
First Name: Binod
Last Name: Ratha
Address: BAL
Telephone Number: 5558987845
Position: programmer
Gender: M
Start Date: 20/6/2001
DOB: 25/1/2004
Salary $8900067.0

1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 2

Enter the starting character of last name to search: p

Employee ID: 112
Social Security Number: 112456
First Name: Sasmita
Last Name: Panda
Address: BBSR
Telephone Number: 2245879123
Position: secretary
Gender: F
Start Date: 12/2/1999
DOB: 10/4/2001
Salary $80000.0

Employee ID: 114
Social Security Number: 894114
First Name: Manvi
Last Name: Panda
Address: GAT
Telephone Number: 2356894587
Position: Manager
Gender: F
Start Date: 20/11/1911
DOB: 22/11/1911
Salary $79000.0

Employee ID: 115
Social Security Number: 654115
First Name: Bishnu
Last Name: Prasad
Address: BBSR
Telephone Number: 32644456987
Position: engineer
Gender: M
Start Date: 15/12/2004
DOB: 11/12/2004
Salary $56000.0

Employee ID: 119
Social Security Number: 155619
First Name: Sunil
Last Name: Padhy
Address: CCR
Telephone Number: 3366545569
Position: Manager
Gender: M
Start Date: 14/11/1988
DOB: 18/13/2007
Salary $45000.0

Employee ID: 122
Social Security Number: 991722
First Name: Manvi
Last Name: Panda
Address: RKL
Telephone Number: 6669899998
Position: engineer
Gender: F
Start Date: 17/10/2006
DOB: 19/3/2006
Salary $72000.0

Employee ID: 130
Social Security Number: 559130
First Name: Tanvi
Last Name: Padhy
Address: BET
Telephone Number: 3326548995
Position: President
Gender: F
Start Date: 27/2/2018
DOB: 17/6/2016
Salary $32000.0

1 Find out the employees earns more than given salary.
2 Find out the employees last name satarts with given character.
3 Quit.
Enter your choice: 3

Add a comment
Know the answer?
Add Answer to:
JAVA ONLY. For this assignment you will create an employee application, containing contact information, salary, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a Java application, that support the following: Create an Employee class, which holds following information:...

    Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...

  • In this assignment, you will create an application that holds a list of contact information. You ...

    In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. MUST BE IN PYTHON FORMAT Create the folllowing objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...

  • In this assignment, you will create an application that holds a list of contact information. You...

    In this assignment, you will create an application that holds a list of contact information. You will be able to prompt the user for a new contact, which is added to the list. You can print the contact list at any time. You will also be able to save the contact list. Must Be In Python Format Create the following objects: ContactsItem - attributes hold the values for the contact, including FirstName - 20 characters LastName - 20 characters Address...

  • I need help with this Java program: ** Note, the main function should be in its...

    I need help with this Java program: ** Note, the main function should be in its own class. The application simulates a mobile phone with a Contacts application. The mobile phone must be able to store, modify, query, and remove contact names. The Contacts class will contain the name. phone number, and email of contacts. Use composition to demonstrate the Mobile Phone class to contains an array of Contacts. The Mobile Phone class should provide a menu of options to...

  • In Java: Executable Class create an array of Employee objects. You can copy the array you...

    In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...

  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

  • IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table...

    IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table class to hold employees and their ID numbers. You'll create an employee class to hold each person's key (id number) and value (name). Flow of the main program: Create an instance of your hash table class in your main method. Read in the Employees.txt file and store the names and ID numbers into Employee objects and store those in your hash table using the...

  • in a java application need  to create an application which prompts the user numerator and denominator values...

    in a java application need  to create an application which prompts the user numerator and denominator values then show the result of the division.  The application will use exception handling to verify the user has entered valid input and will continue to prompt the user for input as long as the value they enter is invalid.  Once the user has entered valid numerator and denominator values, the result is shown and the application exits. had some issues when I entered letters instead of...

  • Create a database that will record employees and their salary histories. For each employee record their...

    Create a database that will record employees and their salary histories. For each employee record their first name, last name, DOB and start date and termination date (if applicable). The salary history should include the $s alary, the range of dates for which the salary is effective (the current salary will not have an end date). The database should also record a history of which departments they have worked for. An employee may only work for one department at a...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT