Calculating Interest Based Problem in Java
Calculating Interest Based Problem in Java
Calculate interest based on the type of the account and the status of the account
holder. The rates of interest changes according to the amount (greater than or less
than 1 crore), age of account holder (General or Senior citizen) and number of days
if the type of account is FD or RD.
CODE:
import java.util.*;
class FDAccount{
double amount;
int noOfDays;
int ageofAcHolder;
amount = b;
noOfDays = c;
ageofAcHolder = d;
}
double interestgain = 0.0;
void calculateInterest(){
if(amount<10000000){
if(ageofAcHolder>=60){
if(noOfDays>=7 && noOfDays<=14){
interestgain = (amount*5.00)/100;
}
else if(noOfDays>=15 && noOfDays<=29){
interestgain = (amount*5.25)/100;
}
else if(noOfDays>=30 && noOfDays<=45){
interestgain = (amount*6.00)/100;
}
else if(noOfDays>=45 && noOfDays<=60){
interestgain = (amount*7.50)/100;
}
else if(noOfDays>=61 && noOfDays<=184){
interestgain = (amount*8.00)/100;
}
else if(noOfDays>=185 && noOfDays<=365){
interestgain = (amount*8.50)/100;
}
System.out.println("Interestgain: "+interestgain);
}
else{
if(noOfDays>=7 && noOfDays<=14){
interestgain = (amount*4.50)/100;
}
else if(noOfDays>=15 && noOfDays<=29){
interestgain = (amount*4.75)/100;
}
else if(noOfDays>=30 && noOfDays<=45){
interestgain = (amount*5.50)/100;
}
else if(noOfDays>=45 && noOfDays<=60){
interestgain = (amount*7.00)/100;
}
else if(noOfDays>=61 && noOfDays<=184){
interestgain = (amount*7.50)/100;
}
else if(noOfDays>=185 && noOfDays<=365){
interestgain = (amount*8.00)/100;
}
System.out.println("Interestgain: "+interestgain);
}
}
else{
if(noOfDays>=7 && noOfDays<=14){
interestgain = (amount*6.50)/100;
}
else if(noOfDays>=15 && noOfDays<=29){
interestgain = (amount*6.75)/100;
}
else if(noOfDays>=30 && noOfDays<=45){
interestgain = (amount*6.75)/100;
}
else if(noOfDays>=45 && noOfDays<=60){
interestgain = (amount*8.00)/100;
}
else if(noOfDays>=61 && noOfDays<=184){
interestgain = (amount*8.50)/100;
}
else if(noOfDays>=185 && noOfDays<=365){
interestgain = (amount*10.00)/100;
}
System.out.println("Interestgain: "+interestgain);
}
}
}
class RDAccount{
double amount;
int noOfmonths;
int ageofAcHolder;
if(ageofAcHolder>=65){
if(noOfmonths>=6 && noOfmonths<9){
interestgain = (amount*8.00)/100;
}
else if(noOfmonths>=9 && noOfmonths<12){
interestgain = (amount*8.25)/100;
}
else if(noOfmonths>=12 && noOfmonths<15){
interestgain = (amount*8.50)/100;
}
else if(noOfmonths>=15 && noOfmonths<18){
interestgain = (amount*8.75)/100;
}
else if(noOfmonths>=18 && noOfmonths<21){
interestgain = (amount*9.00)/100;
}
else if(noOfmonths>=21 && noOfmonths<=24){
interestgain = (amount*9.25)/100;
}
System.out.println("Interestgain "+ interestgain);
}
else{
if(noOfmonths>=6 && noOfmonths<9){
interestgain = (amount*7.50)/100;
}
else if(noOfmonths>=9 && noOfmonths<12){
interestgain = (amount*7.75)/100;
}
else if(noOfmonths>=12 && noOfmonths<15){
interestgain = (amount*8.00)/100;
}
else if(noOfmonths>=15 && noOfmonths<18){
interestgain = (amount*8.25)/100;
}
else if(noOfmonths>=18 && noOfmonths<21){
interestgain = (amount*8.50)/100;
}
else if(noOfmonths>=21 && noOfmonths<=24){
interestgain = (amount*8.75)/100;
}
System.out.println("Interestgain "+ interestgain);
}
}
}
class SBaccount{
double amount;
String accountType;
OUTPUT:
Learning Outcomes: