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


Please Help Members By Posting Answers For Below Questions

Can a singleton class be inherited?

520


How to sort array of 0 and 1 in java?

541


What is the importance of static variable?

584


What is java and its types?

549


what is meant by Garbage collection?

616






What is a vector in java?

574


What is http client in java?

515


What is boolean data type in java?

562


What do you mean by Function Overloading in java?

624


What are the characteristics of Final,Finally and Finalize keywords.

694


What is an abstract class and what is it’s purpose?

533


What is command line argument in java?

603


Why you should not use singleton?

536


How is java hashmap implemented?

546


What are the different types of sorting in java?

539