There is a Banking application. It has 2 types of account,
Savings and Current. Write a method calculateInterest by
passing an ArrayList of these account objects and calculate
Interest accordingly. Write code for this situation
Answer Posted / 94374
public class CalculateInterst {
public static double calculateInterest (List list){
double intrest = 0;
if(list != null && list.get(0).equals("SAVING")){
//Calculate interest for Saving Account and return it
intrest = 7.0;
}else if (list != null && list.get(1).equals("CURRENT")){
//Calculate interest for Saving Account and return it
intrest = 5.0;
}
return intrest;
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("SAVING");
list.add("CURRENT");
calculateInterest(list);
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?
What is output buffer?
Write a function for palindrome and factorial and explain?
What is void in java?
What is meant by 'Class access modifiers'?
How many functional interfaces does java 8 have?
How is it possible for two string objects with identical values not to be equal under the == operator?
What will happen when using pass by reference in java?
Is java se free?
What is class array in java?
Can you explain the private protected field modifier?
Why do we use threads in java?
How many bits is size_t?
Can a class extends itself in java?
Is array a class in java?