+ 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

16th Oct 2017, 7:06 PM
I_aM_cArly
I_aM_cArly - avatar
1 Odpowiedź
+ 4
Thanks that took care of it.
16th Oct 2017, 8:15 PM
I_aM_cArly
I_aM_cArly - avatar