For the below code in JAVA, how could I make it like a switch statement that giv
ID: 3700607 • Letter: F
Question
For the below code in JAVA, how could I make it like a switch statement that gives the user the option to navigate a menu that allows them to either search for jobs, employers or applicants and displays the results to screen. I need it to be able to search for key words. i need to make it capable of storing the applicant, employer, and job posting data to a txt file and loading the data with the use of an array or arraylist? Basically I need it to store to a text file and be able to keyword search for a string.
package jobseekapp;
import java.util.Scanner;
public class JobSeekApp {
public static void main(String[] args) {
Employers[] emp = new Employers[5];
Applicants[] app = new Applicants[5];
Jobs[] job = new Jobs[5];
// create employee
emp[0] = new Employers("Nath", "Muellner", "nmuellner@technopark.com", "1-213-233-9474", 37, 10, "LA",
"TechnoPark", "HR");
emp[1] = new Employers("Mark", "Jamison", "mjamison@itpark.com", "1-213-262-7463", 35, 5, "LA", "ITPark",
"Manager");
emp[2] = new Employers("Paul", "Gregory", "pgregory@technicalinnovations.com", "1-213-343-2312", 43, 12, "LA",
"Technical Innovations", "Manager");
emp[3] = new Employers("Harrison", "Jones", "jharrison@sebring.com", "1-213-234-4332", 34, 4, "LA",
"Sebring Techonologies", "HR");
emp[4] = new Employers("Chris", "Lawrence", "clawrence@createch.com", "1-213-231-3532", 29, 2, "LA", "Createch",
"Manager");
// create applicants
// create jobs
app[0] = new Applicants("Samantha", "Michaels", "smichaels@google.com", "1-213-212-2321", 30, "BS", 5, "LA",
"Programmer");
app[1] = new Applicants("George", "Peterson", "gpeterson@yahoo.com", "1-212-434-2322", 24, "MBA", 3, "LA",
"Manager");
app[2] = new Applicants("Katie", "Harris", "kharris@hotmail.com", "1-213-232-1112", 28, "BS", 5, "LA",
"Database Administrator");
app[3] = new Applicants("Kevin", "Reynolds", "kreynolds78@google.com", "1-213-653-2313", 39, "MS", 12, "LA",
"Lead Programmer");
app[4] = new Applicants("Renee", "Collins", "rcollins@aol.com", "1-213-456-4352", 47, "MS", 14, "LA", "CEO");
//job postings
job[0] = new Jobs("Technical Innovations", "pgregory@technicalinnovations.com", 75000.23, 5, "LA", "Manager");
job[1] = new Jobs("Sebring Technologies", "jharrison@sebring.com", 100000.40, 5, "LA", "Lead Programmer");
job[2] = new Jobs("IT Park", "mjamison@itpark.com", 85000.23, 3, "LA", "Database Administrator");
job[3] = new Jobs("Createch", "clawrence@createch.com", 70000.24, 3, "LA", "Network Administrator");
job[4] = new Jobs("TechnoPark", "nmuellner@technopark.com", 80000.00, 2, "LA", "Manager")
}
}
Explanation / Answer
package jobseekapp;
import java.util.Scanner;
public class JobSeekApp {
public static void main(String[] args) {
Employers[] emp = new Employers[5];
Applicants[] app = new Applicants[5];
Jobs[] job = new Jobs[5];
// create employee
emp[0] = new Employers("Nath", "Muellner", "nmuellner@technopark.com", "1-213-233-9474", 37, 10, "LA",
"TechnoPark", "HR");
emp[1] = new Employers("Mark", "Jamison", "mjamison@itpark.com", "1-213-262-7463", 35, 5, "LA", "ITPark",
"Manager");
emp[2] = new Employers("Paul", "Gregory", "pgregory@technicalinnovations.com", "1-213-343-2312", 43, 12, "LA",
"Technical Innovations", "Manager");
emp[3] = new Employers("Harrison", "Jones", "jharrison@sebring.com", "1-213-234-4332", 34, 4, "LA",
"Sebring Techonologies", "HR");
emp[4] = new Employers("Chris", "Lawrence", "clawrence@createch.com", "1-213-231-3532", 29, 2, "LA", "Createch",
"Manager");
// create applicants
// create jobs
app[0] = new Applicants("Samantha", "Michaels", "smichaels@google.com", "1-213-212-2321", 30, "BS", 5, "LA",
"Programmer");
app[1] = new Applicants("George", "Peterson", "gpeterson@yahoo.com", "1-212-434-2322", 24, "MBA", 3, "LA",
"Manager");
app[2] = new Applicants("Katie", "Harris", "kharris@hotmail.com", "1-213-232-1112", 28, "BS", 5, "LA",
"Database Administrator");
app[3] = new Applicants("Kevin", "Reynolds", "kreynolds78@google.com", "1-213-653-2313", 39, "MS", 12, "LA",
"Lead Programmer");
app[4] = new Applicants("Renee", "Collins", "rcollins@aol.com", "1-213-456-4352", 47, "MS", 14, "LA", "CEO");
//job postings
job[0] = new Jobs("Technical Innovations", "pgregory@technicalinnovations.com", 75000.23, 5, "LA", "Manager");
job[1] = new Jobs("Sebring Technologies", "jharrison@sebring.com", 100000.40, 5, "LA", "Lead Programmer");
job[2] = new Jobs("IT Park", "mjamison@itpark.com", 85000.23, 3, "LA", "Database Administrator");
job[3] = new Jobs("Createch", "clawrence@createch.com", 70000.24, 3, "LA", "Network Administrator");
job[4] = new Jobs("TechnoPark", "nmuellner@technopark.com", 80000.00, 2, "LA", "Manager");
// NOW SWITCH STATEMENT
int n, i;
Scanner s= new Scanner(System.in);
i=s.nextInt();
System.out.println(" Enetr your choice:: 1)employees 2) Applicants 3)Jobs");
switch(i)
{ Case 1: System.out.println(" Choose the employee ID=");
int n=s.nextInt();
System.out.println("employee u selected is="+emp[n]);
Case 2: System.out.println(" Choose the applicant ID=");
int n=s.nextInt();
System.out.println("Applicant u selected is="+app[n]);
Case 3: System.out.println(" Choose the Job ID=");
int n=s.nextInt();
System.out.println("Job u selected is="+job[n]);
Default: System.out.println("Wrong Choice");
}
}
}