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
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 |
what is connection pooling with example?
How do you check whether the list is empty or not in java?
How the interruptible method gets implemented?
What is the return type of read()?
How to reduce flicking in animation?
what is the volatile modifier for? : Java thread
Explain the importance of finally over return statement?
Difference between String & StringBuffer
16 Answers IBM, Infosys, Tech Mahindra, Wipro,
Which are thin and thicK wrapper Class's in Java?
Why multiple inheritance is not supported by java?
What are loops in java?
What is an escape character in java?