Consider the following class. The method getTotalSalaryAndBonus is intended to return an employee's total salary with the bonus added. The bonus should be doubled when the employee has 10 or more years of service.
public class Employee
{
private String name;
private double salary;
private int yearsOfService;
public Employee(String n, double sal, int years)
{
name = n;
salary = sal;
yearsOfService = years;
}
public double getTotalSalaryAndBonus(double bonus)
{
/ missing code /
}
}
Which of the following could replace / missing code / so that method getTotalSalaryAndBonus will work as intended?
A.
if (years >= 10)
{
bonus *= 2;
}
return salary + bonus;
B.
if (yearsOfService >= 10)
{
bonus *= 2;
}
return salary + bonus;
C.
return salary + bonus;
D.
if (years >= 10)
{
bonus *= 2;
}
return sal + bonus;
E.
if (yearsOfService >= 10)
{
bonus *= 2;
}
return sal + bonus;