The answer should be returned but it does not display for some reason. I have printed within for loop and seen that it’s correct answer.
public class Salary
{
public static void main (String[]args)
{
double [] salary = {20000.00};
double riseRate = 1.07;
calculateSalary(salary, riseRate);
}
public static double [] calculateSalary(double [] salary, double riseRate)
{
for (int i=0; i<salary.length; i++)
{
salary [i] = salary [i] * riseRate;
}
return salary;
}
}
You are returning an array. The salary is in the the first position of you array. If you want to see the salary you would need to use
in your method.
or
in the main.
What you’re trying to print right now is the actual array, not a value.
I am not sure why you are doing it like this, though.
Why not just use a double instead of double[]?