+ 2
Overloading methods
I am trying to create an overloaded method to calculate an employee's rating whereby an integer is outputted when a String is entered in the console by the user. The first method I used to accomplish this was: public double calculateBonus(String rating) { if (rating.equals("excellent")) { Bonus = 500; } else if (rating.equals("satisfactory")) { Bonus = 300; } else if (rating.equals("other")) { Bonus = 0; } return Bonus; } What're alternative methods of accomplishing this? Thank you
1 Respuesta
+ 4
Thanks that took care of it.