I'm making a payroll program and one of the options is to check data on current users. I want to allow the user to enter either the employee's ID or name to retrieve this information.
Scanner userChoice = new Scanner(System.in);
System.out.println("Enter employee ID or full name");
String checkHEmp = userChoice.next();
int checkHempID = userChoice.nextInt();
if (checkHempID ==3|| checkHEmp == "Jill Jones") {
HourlyEmployee jones = new HourlyEmployee();
jones.jJones();
}
In this example HourlyEmployee is a class of hourly employees and jJones() is a method in that class that contains the information for one of the employees. When I enter either "3" (the ID) or "Jill Jones" nothing happens afterwards.
Edit: Added method for jJones()
public void jJones() {
double hourlyWagesJones = 16.45;
double hoursWorkedJones = 48;
System.out.println("Employee ID: 3");
System.out.println("Last name: Jones");
System.out.println("First name: Jill");
System.out.println("Date Hired: 1/22/2011");
System.out.println("Hours Worked: " + hoursWorkedJones);
System.out.println("Hourly Wages: $" + hourlyWagesJones);
double totalEarnedJones = new Double(hourlyWagesJones * hoursWorkedJones);
System.out.println("Total earned: $" + totalEarnedJones);
}