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



There is a Banking application. It has 2 types of account, Savings and Current. Write a method calc..

Answer / 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

More Core Java Interview Questions

What is contractor means and methods?

0 Answers  


Explain importance of inheritance in java?

0 Answers  


Why do I need to declare the type of a variable in java?

0 Answers  


What are facelets templates?

0 Answers  


What is the internal implementation of set in java?

0 Answers  






Can we assign null to double in java?

0 Answers  


How to reverse string in java?

0 Answers  


What is the difference between overloading and overriding a function?

13 Answers   eG Innovations, Infosys, TCS,


How many types of design patterns are there?

0 Answers  


What is numeric data type?

0 Answers  


Suppose there is an array list [10,5,20,19,15,24].Print them in ascending & descending order in collection framework concept ???

2 Answers   Cognizant,


what is difference between class and object?

43 Answers   College School Exams Tests, HCL,


Categories