All the banks operating in India are controlled by RBI. RBI has set a well defined guideline (e.g. minimum interest rate, minimum balance allowed, maximum withdrawal limit etc) which all banks must follow. For example, suppose RBI has set minimum interest rate applicable to a saving bank account to be 4% annually; however, banks are free to use 4% interest rate or to set any rates above it.
Write a java program to implement bank functionality in the above scenario. Note: Create few classes namely Customer, Account, RBI (Base Class) and few derived classes (SBI, ICICI, PNB etc). Assume and implement required member variables and functions in each class.
package bank;
import java.util.Scanner;
class Customer{
protected String name, address;
protected int age;
}
class Account{
protected String accountType, branchType;
}
class RBI{
public int withLimit, n;
public double P, r, t, averageAmount, totalAmount;
void setData(double P, double r, int n, double t){
this.P = P;
this.t =t;
this.n = n;
this.r = r;
}
int set_withdrawal_limit() {
String accountType, branchType;
System.out.println("Enter account type\n");
Scanner scan = new Scanner(System.in);
accountType = scan.next();
System.out.println("Enter branch type\n");
branchType = scan.next();
if (accountType == "SAVINGS" && branchType == "METRO") {
withLimit = 5000;
} else {
withLimit = 4000;
}
return withLimit;
}
double setInterestRate() {
return (P + r) / n * t;
}
double setMAB() {
return (averageAmount + totalAmount) / 31;
}
};
class SBI extends RBI {
double setInterestRate() {
return P * (1 + r / n) + n * t;
}
double set_MAB() {
return (averageAmount + totalAmount) / 30;
}
}
public class Bank {
public static void main(String[] args) {
RBI r = new RBI();
SBI s = new SBI();
s.setData(10.433, 7.42, 5, 7);
System.out.println("The interest rate is: \n"+s.setInterestRate());
}
}
Comments
Leave a comment