I'm trying to find the employee's salary by entering their rating of excellent, good, or poor through the scanner input. I'm trying to use the if statements to do so but the output is the else statement Wrong input
.
import java.util.Scanner;
public class Salary {
public static void main(String[] args) {
double Currentsalary;
double raise;
double newraise = 0;
String rating;
Scanner scan = new Scanner(System.in);
System.out.print("Enter employees current Salary ");
Currentsalary = scan.nextDouble();
System.out.print("Enter employees rating (good, excellent or poor):");
rating = scan.next();
if (rating == "excellent") {
raise = 6/100 * Currentsalary;
newraise = raise + Currentsalary;
}
if (rating == "good") {
raise = 4/100 * Currentsalary;
newraise = raise + Currentsalary;
}
if(rating == "poor") {
raise =1.5/100 * Currentsalary;
newraise = raise + Currentsalary;
}
else {
System.out.println("Wrong input");
}
System.out.println("Employees new salary is :"+ newraise);
}
}