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

What is application system?

583


Is java good for beginners?

662


What is a local, member and a class variable?

662


What is byte value?

637


How to solve the problem of generating the unique hash keys with hash function?

1547






Why we use protected in java?

624


How do you remove an object from an arraylist in java?

544


What are the escape sequences in java?

655


Why are lists ordered in java?

655


Is java ee a framework?

618


What is a Transient Object?

723


Is the empty set a singleton?

626


Why is java called the platform independent programming language?

676


Can a final method be overloaded?

600


What is a “stateless” protocol ?

651