Answer:
The printItem() method code is filled in the explanation, highlighted with bold font.
Explanation:
// ===== Code from file BaseItem.java =====
public class BaseItem {
protected String lastName;
public void setLastName(String providedName) {
lastName = providedName;
return;
}
// FIXME: Define printItem() method
/* Your solution goes here */
public void printItem() {
// TODO Auto-generated method stub
System.out.println("Last name: "+lastName);
}
}
// ===== end =====
<em>After you design and write your help-desk procedures to solver the problem, the next step would be, testing and implementation.
</em>
<em>
</em>
<em>Basically, in any problem-solving process, after planning and designing the solutions, the next process that should be implemented next is: testing and implementation. In the testing phase, staff and employees would implement the solution softly, meaning everything is not advertised yet and not formal yet. They would execute the plan and design and would evaluate if it is really effective. A documentation will prepare as the basis of the evaluation. After the testing, the project team would determine if the offered solution is possible or if there are more improvements to make.</em>
Answer:
The complete method is as follows:
public static int divBySum(int[] arr, int num){
int sum = 0;
for(int i:arr){
if(i%num == 0)
sum+=i;
}
return sum;
}
Explanation:
As instructed, the program assumes that arr has been declared and initialized. So, this solution only completes the divBySum method (the main method is not included)
This line defines the method
public static int divBySum(int[] arr, int num){
This line declares and initializes sum to 0
int sum = 0;
This uses for each to iterate through the array elements
for(int i:arr){
This checks if an array element is divisible by num (the second parameter)
if(i%num == 0)
If yes, sum is updated
sum+=i;
}
This returns the calculated sum
return sum;
}