If Else Statement using String
Hello,
I am having some issues with a small program I have to complete for my Java class. Basically, the program will determine a worker's raise based on their current salary. It will first ask for the current salary, and then for a performance rating (Excellent, Good, or Poor). An Excellent rating will receive a 6% raise, a Good rating will receive a 4% raise, and a Poor rating will receive a 1.5% raise.
Requirements ask for an If Else statement to compute the raise. I have tried many different String mutations with no luck. So far I have the following:
import java.util.Scanner;
import java.text.NumberFormat;
public class Salary
{
public static void main (String[] args)
{
double currentSalary; // employee's current salary
double raise; // amount of the raise
double newSalary; // new salary for the employee
String rating;// performance rating
Scanner scan = new Scanner(System.in);
System.out.print (" Enter the current salary: ");
currentSalary = scan.nextDouble();
System.out.print (" Enter the Performance Rating (Excellent, Good, or Poor): ");
rating = scan.next();
***From here, what do I need to do in order to have the rating (Excellent, Good, or Poor) changed in order to use an If Else Statement?***
// Compute the raise using if ...
if (????)
{
raise = (currentSalary * .06);
}
else if (???)
{
raise = (currentSalary * .04);
}
else
{
raise = (currentSalary * .015);
}
newSalary = (currentSalary + raise);
// Print the results
NumberFormat money = NumberFormat.getCurrencyInstance();
System.out.println();
System.out.println(" Current Salary: " + money.format(currentSalary));
System.out.println(" Amount of your raise: " + money.format(raise));
System.out.println(" Your new salary: " + money.format(newSalary));
System.out.println();
}
}
Thanks in advance for any Pointers!