Write a class Employee. An employee has a private first name (string), private last name (string), private job title (string), private employment ID (string), private monthly income (double), private joining date (string), and private mailing address (string). Provide a default constructor, a parameterized constructor, and a clone constructor. Write separate setters and getters for each private instance variable. Your Employee class should also keep track of number of employees that have been added to your system.

Write another class BusinessConcern, which acts as your main class. Inside main method, create a one-dimensional array of objects of Employee type. At the start of your program, it should prompt for total number of employee records to be added to the system. After creating an array of desired number of employees, your program shall provide a console-based menu to user with following options:
1) New Employee Record (input: values for initialization of instance variables of new employee object/instance)
2) Change Job Title (required input: employment ID, new job title)
3) Change Monthly Income (required input: employment ID, new monthly income)
4) Change Mailing Address (required input: employment ID, new mailing address)
5) Employee Details (required input: employment ID)
6) List All Available Records
7) Exit Program
I have been working on this project for quit some hours .... But it seems to be not working ... here is the class Employee

import javax.swing.JOptionPane;
class Employee
{
private String firstName;
private String lastName;
private String jobTitle;
private String employeeID;
private double monthlyIncome;
private String joiningDate;
private String mailingAddress;
static int count=0;

Employee()
{
firstName=" " ;
lastName=" " ;
jobTitle=" " ;
employeeID=" " ;
monthlyIncome=0.0;
joiningDate=" " ;
mailingAddress=" " ;
count++;
}
Employee(String f,String l,String j,String e,double m,String join,String mail)
{
firstName=f ;
lastName=l ;
jobTitle=j ;
employeeID=e ;
monthlyIncome=m;
joiningDate=join ;
mailingAddress=mail ;
count++;
}
Employee(Employee emp)
{
firstName=emp.firstName;
lastName=emp.lastName;
jobTitle=emp.jobTitle ;
employeeID=emp.employeeID ;
monthlyIncome=emp.monthlyIncome;
joiningDate=emp.joiningDate ;
mailingAddress=emp.mailingAddress ;
count++;
}

void setfirstName(String f)
{
firstName=f;
}
void setlastName(String l)
{
lastName=l;
}
void setjobTitle(String j)
{
jobTitle=j;
}
void setemployeeID(String e)
{
employeeID=e;
}
void setmonthlyIncome(double m)
{
monthlyIncome=m;
}
void setjoiningDate(String join)
{
joiningDate=join;
}
void setmailingAddress(String mail)
{
mailingAddress=mail;
}

String getfirstName()
{
return firstName;
}
String getlastName()
{
return lastName;
}
String getjobTitle()
{
return jobTitle;
}
String getemployeeID()
{
return employeeID;
}
double getmonthlyIncome()
{
return monthlyIncome;
}
String getjoiningDate()
{
return joiningDate;
}
String getmailingAddress()
{
return mailingAddress;
}
//NEW EMPLOYEE
void NewEmployee()
{
String f=JOptionPane.showInputDialog("Enter your First Name:");
setfirstName(f);
String l=JOptionPane.showInputDialog("Enter your Last Name:");
setlastName(l);
String j=JOptionPane.showInputDialog("Enter your Job Title:");
setjobTitle(j);
String e=JOptionPane.showInputDialog("Enter your Employee ID:");
setemployeeID(e);
double m=Double.parseDouble(JOptionPane.showInputDialog("Enter your Monthly Income:"));
setmonthlyIncome(m);
String join=JOptionPane.showInputDialog("Enter your Joining Date:");
setjoiningDate(join);
String mail=JOptionPane.showInputDialog("Enter your Mailing Address:");
setmailingAddress(mail);
}
//JOB TITLE
void JobTitle(String empID,Employee[] list,String n)
{
String test;
for(int i=0;i<list.length;i++){
test=list[i].getjobTitle();
if(empID.equals(test)){
System.out.println("found it !");
list[i].setjobTitle(n);
System.out.println("Your Job Title has been changed to "+ list[i].getjobTitle());
}
else
continue;
}
}
/*void JobTitle(Employee[] list)
{
String empID=JOptionPane.showInputDialog("Enter your Employee ID:");
String n=JOptionPane.showInputDialog("Enter your New Job Title:");
for(int i=0;i<list.length;i++){
if(empID.equals(list[i].getjobTitle())){
list[i].setjobTitle(n);
System.out.println("Your Job Title has been changed to "+ list[i].getjobTitle());
}
else
continue;
}
}*/
}//FINAL BRACKET

and here is the BusinessConcern class which also the main class ...

import java.util.Scanner;
import javax.swing.JOptionPane;
class BusinessConcern{
public static void main(String []args){
String empID,n;
//Scanner enter=new Scanner(System.in);
//System.out.print("How many account(s) do wish to create ? ");
//int num=enter.nextInt();
int num=Integer.parseInt(JOptionPane.showInputDialog("How many account(s) do wish to create ? "));
Employee acc[]=new Employee[num];
for(int i=0;i<acc.length;i++){
acc[i]=new Employee();

int choice=0;

System.out.println("What do you want to do ? ");
System.out.println("New Employee (1)");
System.out.println("Change Job Title (2)");
System.out.println("Change Monthly Income (3)");
System.out.println("Change Mailing Address (4)");
System.out.println("Employee Details (5)");
System.out.println("Available Records (6)");
System.out.println("Exit (7)");

choice=Integer.parseInt(JOptionPane.showInputDialog("Enter your choice"));

switch(choice){
case 1:
acc[i].NewEmployee();
System.out.println(acc[i].getjobTitle());
break;
case 2:
empID=JOptionPane.showInputDialog("Enter your Employee ID:");
n=JOptionPane.showInputDialog("Enter your New Job Title:");
acc[i].JobTitle(empID,acc,n);
break;
case 7:
System.exit(0);
break;

}
}

}//2ND LAST
}//LAST BRACKET

Thanks in Advance .

this is what i did

import java.util.Scanner;
import javax.swing.JOptionPane;
class BusinessConcern{
public static void main(String []args){
String empID,n;
//Scanner enter=new Scanner(System.in);
//System.out.print("How many account(s) do wish to create ? ");
//int num=enter.nextInt();
int num=Integer.parseInt(JOptionPane.showInputDialog("How many account(s) do wish to create ? "));
Employee acc[]=new Employee[num];
for(int i=0;i<acc.length;i++){
acc[i]=new Employee();

int choice=0;

System.out.println("What do you want to do ? ");
System.out.println("New Employee (1)");
System.out.println("Change Job Title (2)");
System.out.println("Change Monthly Income (3)");
System.out.println("Change Mailing Address (4)");
System.out.println("Employee Details (5)");
System.out.println("Available Records (6)");
System.out.println("Exit (7)");

choice=Integer.parseInt(JOptionPane.showInputDialog("Enter your choice"));

switch(choice){
case 1:
acc[i].NewEmployee();
System.out.println(acc[i].getjobTitle());
break;

case 2:
empID=JOptionPane.showInputDialog("Enter your Employee ID:");

/*acc[i].JobTitle(empID,acc,n);
break;*/
for(int j=0;j<acc.length;j++){
if(empID.equals(acc[i].getjobTitle())){
acc[i].JobTitle();
System.out.println(acc[i].getjobTitle());
}
}
break;
case 7:
System.exit(0);
break;

}
}

}//2ND LAST
}//LAST BRACKET

and what i comprehended ...

import javax.swing.JOptionPane;
class Employee
{
private String firstName;
private String lastName;
private String jobTitle;
private String employeeID;
private double monthlyIncome;
private String joiningDate;
private String mailingAddress;
static int count=0;

Employee()
{
firstName=" " ;
lastName=" " ;
jobTitle=" " ;
employeeID=" " ;
monthlyIncome=0.0;
joiningDate=" " ;
mailingAddress=" " ;
count++;
}
Employee(String f,String l,String j,String e,double m,String join,String mail)
{
firstName=f ;
lastName=l ;
jobTitle=j ;
employeeID=e ;
monthlyIncome=m;
joiningDate=join ;
mailingAddress=mail ;
count++;
}
Employee(Employee emp)
{
firstName=emp.firstName;
lastName=emp.lastName;
jobTitle=emp.jobTitle ;
employeeID=emp.employeeID ;
monthlyIncome=emp.monthlyIncome;
joiningDate=emp.joiningDate ;
mailingAddress=emp.mailingAddress ;
count++;
}

void setfirstName(String f)
{
firstName=f;
}
void setlastName(String l)
{
lastName=l;
}
void setjobTitle(String j)
{
jobTitle=j;
}
void setemployeeID(String e)
{
employeeID=e;
}
void setmonthlyIncome(double m)
{
monthlyIncome=m;
}
void setjoiningDate(String join)
{
joiningDate=join;
}
void setmailingAddress(String mail)
{
mailingAddress=mail;
}

String getfirstName()
{
return firstName;
}
String getlastName()
{
return lastName;
}
String getjobTitle()
{
return jobTitle;
}
String getemployeeID()
{
return employeeID;
}
double getmonthlyIncome()
{
return monthlyIncome;
}
String getjoiningDate()
{
return joiningDate;
}
String getmailingAddress()
{
return mailingAddress;
}
//NEW EMPLOYEE
void NewEmployee()
{
String f=JOptionPane.showInputDialog("Enter your First Name:");
setfirstName(f);
String l=JOptionPane.showInputDialog("Enter your Last Name:");
setlastName(l);
String j=JOptionPane.showInputDialog("Enter your Job Title:");
setjobTitle(j);
String e=JOptionPane.showInputDialog("Enter your Employee ID:");
setemployeeID(e);
double m=Double.parseDouble(JOptionPane.showInputDialog("Enter your Monthly Income:"));
setmonthlyIncome(m);
String join=JOptionPane.showInputDialog("Enter your Joining Date:");
setjoiningDate(join);
String mail=JOptionPane.showInputDialog("Enter your Mailing Address:");
setmailingAddress(mail);
}
//JOB TITLE
void JobTitle()
{
String n=JOptionPane.showInputDialog("Enter your New Job Title:");
setjobTitle(n);
}
/*void JobTitle(Employee[] list)
{
String empID=JOptionPane.showInputDialog("Enter your Employee ID:");
String n=JOptionPane.showInputDialog("Enter your New Job Title:");
for(int i=0;i<list.length;i++){
if(empID.equals(list[i].getjobTitle())){
list[i].setjobTitle(n);
System.out.println("Your Job Title has been changed to "+ list[i].getjobTitle());
}
else
continue;
}
}*/
}//FINAL BRACKET

Plz javaAddict help me out .... as helped me before ....

Follow the instructions at the link.
Also at the options where the user enters employee number, loop through the array until you find the employee and call that employee's methods. You don't loop the array and call everybody's method, only the employee that has the employee number that you entered

javaAddict ! plz rectify me here .....

empID=JOptionPane.showInputDialog("Enter your Employee ID:");

/*acc[i].JobTitle(empID,acc,n);
break;*/
for(int j=0;j<Employee.count;j++){
if(empID.equals(acc[i].getjobTitle())){
n=JOptionPane.showInputDialog("Enter your New Job Title:");
acc[i].JobTitle(n);
System.out.println(acc[i].getjobTitle());
}
}
if(empID.equals(acc[i].getjobTitle())) {

}

empId is the employee id, so Why do you compare it with the job title: empID.equals(acc[i].get[B]jobTitle[/B]()) Compare it with the empId of the employee in the array. Then set the job title

This article has been dead for over six months. Start a new discussion instead.