I need to design this program in the simplest way possible and understand so I c
ID: 3806045 • Letter: I
Question
I need to design this program in the simplest way possible and understand so I can do my own code I couldn't figure it out on my own! Thanks
output
Driver
Problem Statement You are going to build a database that an employer can use to keep track of their employees. You will need a way to represent a single employee (name, id number, salary and a way to store an unknown number of employees. You will build the capability to add remove employees from the database and provide some other functionality described below Assignment Create an Outlab5 project and paste this into a Driver. You won't need to change the Driver Here are descriptions of the methods you need o addEmployee. This method reads in a name and salary to represent a new employee. The employee id number is just the number that employee was to join the company. I e. The first employee added has id number 1, the second id number 2, and so on. If an employee ends up leaving the company, employee numbers stay the same and new employees are still given the next number. E g. If employee 1 leaves, employee 2 stays employee 2 o removeEmployee. This method removes an employee from the database based on the employee id number passed. I If employee 123 is to be removed, find the employee with id number 123 and remove them. If that employee does not exist, print an error message. o print Alphabetically. This method will print out all the employees in the database in alphabetical order o printByld. This method will print out all the employees in the database by order of their id numbers starting with employee 1. If some employee (e.g. employee number 7) is no longer in the database, just skip that number. o pay Increase. Give each employee a pay increase of X% where X is the input parameter o getPayroll Cost. Return the total amount of salary of all the employees in the database. Here is some sample output.Explanation / Answer
Let me write a program which describes all your methods. Firstly start with the following methods i.e, as follows:-
a) addEmployee:- The addEmployee methods will add the new list of employeers in the employee table,
I have attached the program here along with the comments in the code:-
Code:-
/* Import statements are used for possible references to information and methods in other respective packages.*/
import java.util.*;
import java.util.Scanner;
public class EmployeeDatabase {
/* The List interface contains two famous classes i.e, ArrayList and LinkedList */
static List<Integer> l=new ArrayList<Integer>();
/* The main() method is the starting point of the application which is served by the Java virual Machine(JVM) */
public static void main(String[] args) {
/* The Scanner class gives a way to enter the employee details*/
Scanner in=new Scanner(System.in);
boolean z=true;
do{
/* The System.out.println helps us to print the standard output by inputing some value */
System.out.println("Employee Management System");
System.out.println(" 1. Add Employee. 2. Remove Employee. 3 3. Print Alphabetically.");
System.out.println("4. Print By ID Number. 5. Issue Pay Increase. 6. Get Payroll Cost. 7. Quit.");
System.out.println("Please enter your choice > ");
int empChoice=in.nextInt();
/* Here we are making use of swicth statements to differentiate the control flow of program execution */
switch(empChoice)
{
case 1:
insertEmployee();
break;
case 2:
removeEmployee();
break;
case 3:
printEmployeeDetails();
break;
case 4:
printByID();
break;
case 5:
issuePay();
break;
case 6:
getPayrollCost();
break;
case 7:
quit();
break;
default:
System.out.println("bad input");
break;
}
System.out.println("Do you want to process more,If yes, Enter "y". Otherwise "n"? y/n");
String x=in.next();
char ch=x.charAt(0);
if( ch=='n')
z=false;
}
while(z!=false);
}
//*************************************************************************************
static public void insertEmployee(){
Scanner in=new Scanner(System.in);
boolean z=true;
do{
System.out.println(" Name? > ");
System.out.println(" Salary? > ");
int num=in.nextInt();
if(num==0)
System.out.println("The number 0 is not alowed as an input type");
else
l.add(num);
System.out.println("Do you want to process more,If yes, Enter "y". Otherwise "n"? y/n");
String x=in.next();
char ch=x.charAt(0);
if( ch=='n')
z=false;
}
while(z!=false);
}
//*************************************************************************************8
static public void printEmployeeDetails(){
if(l.isEmpty())
System.out.println("The list is empty ");
else
for(int i=0 ; i<l.size();i++)
System.out.println("Name"+i+" : "+ l.get(i)+" ");
}
//*************************************************************************************8
static public void printByID(){
if(ld.isEmpty())
System.out.println("The list is empty");
else
for(int i=0 ; i<ld.size();i++)
System.out.println("Name "+i+" : "+ ld.get(i)+" ");
}
//*****************************************************************************8
static public void issuePay(){
Scanner in=new Scanner(System.in);
int num1,num2;
num2=in.nextInt();
if(num2==0)
ystem.out.println("The list is empty ");
else{
try{
System.out.println("Percent Increase (e.g. .02)? >");
num1=in.nextInt();
l.set(num1, num2);
}catch(IndexOutOfBoundsException e){
System.err.println("caught IndexOutOfBoundsException: It is empty "+e.getMessage());
}
}
}
//************************************************************************************************8
static public void removeEmployee(){
Scanner in=new Scanner(System.in);
System.out.println(" ID Number? >");
int num=in.nextInt();
l.remove(num);
}
//***********************************************************************88
static public void getPayrollCost(){
System.out.println(""+ l.size());
}
//******************************************************************************
static public void quit(){
System.exit(0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.