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
Can classes declared using the abstract keyword cab be instantiated?
what are synchronized methods and synchronized statements? : Java thread
Why do I need to declare the type of a variable in java?
What is use of set in java?
Can singleton class be serialized?
What is package private scope in java?
What are the types of java languages?
When can we say that threads are not lightweight process in java?
How to find the largest value from the given array.
What is the reason behind using constructors and destructors?
How do you compare values in java?
What is an i/o filter?
What is the method to declare member of a class static?
What are jee technologies?
What are methods of a class?