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 is identifier give example?
What happens if a constructor is declared private?
Can we assign null to double in java?
How use .contains in java?
Explain access modifiers in java.
Name some OOPS Concepts in Java?
Is there any difference between nested classes and inner classes?
Why hashmap is used in java?
How many bytes is 255 characters?
Explain what access modifiers can be used for variables?
What do you mean by checked exceptions?
How we can declare a static variable?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
What are parameters in a method?
What are namespaces in java?