Overloading methods | SoloLearn: Learn to code for FREE!


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

10/16/2017 7:06:28 PM


4 Answers

New Answer


Thanks that took care of it.