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 are the 3 types of control structures?
How do you remove duplicates in java?
Why declare Main() method as a static in java ?
What is the size of int in 64-bit jvm?
Does java trim remove newline?
What are the types of sockets in java?
How to perform bubble sort in java?
Why method overriding is used?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
Is 0 true or is 1 true?
What are different types of expressions?
What is singleton class and how can we make a class singleton?
When can we say that threads are not lightweight process in java?
What happens when a thrown exception is not handled?
How do you reverse a list?