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

Why is stringbuffer not immutable?

570


Why is the singleton pattern considered to be an anti pattern?

480


What is the difference between yield() and sleep()?

546


How can we make sure main() is the last thread to finish in java program?

675


What are the advantages of packages in java?

576






What are annotations in java?

623


Is an empty arraylist null?

601


What is a generic data type?

574


Difference between ‘is-a’ and ‘has-a’ relationship in java?

543


Why is static used?

555


how to run ecllipse with jettyserver for windows environment using batch file

1497


What is the functionality of the stub?

572


What is the difference between yielding and sleeping in java programming?

588


How do you square a number?

585


Why java is a platform independent? Explain

536