Project 2
All the banks operating in India are controlled by the 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 the minimum interest rate applicable to a savings 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 and demonstrate the OOPs concepts and explain how it is actually satisfying that concept.
Note:
- Create a console application for the banking management system.
- 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.
- In every Bank there should be at least 2 types of account saving and current.
- Saving should give simple interest and Current should provide compound interest on deposited amount.
- In the current account the interest is compounded twice a year (on half yearly its compounded).
- For Every type of account at least 2 users will be there.
- On the running of the application it should ask which bank we want to access.
- Then what type of account you have.
- And then for which user account we want to access.
- Minimum amount for saving account is 2000/- and for current account is 5000/-
- And we can calculate the interest for any given time and total amount as well.
- Interest rates for saving will be 5% annually and for current it will be 8% annually.
- Before calculating interest it should ask the user for how many years you want to calculate it.
- Write code to calculate both types of interests as well for any of the users.
For total amount on Simple Interest:
A = P(1 + rt)
Where:
A = final Amount
P = initial Principal balance
r = annual interest rate
t = time (in years)
So, Total Interest = (A - P)
For total amount on Compound Interest:
π΄ = π(1 + π
π
)
ππ‘
A = final Amount
P = initial Principal balance
r = annual interest rate
t = time (in years)
n = number of times interest is compounded per year
|
Sample Input |
Sample Output |
|
Want to open an account? |
yes/No |
|
If yes, Insert name, type of account and date of birth, in which bank you want |
Account has been opened and account no is: 123 |
|
Want to print mini statement |
If yes, save it in .txt file somewhere |
|
Calculate interest |
If yes, calculate and print |
PROGRAM
package bankproject2chall;
import java.util.Scanner;
public class Customerz {
public static void main(String[] args) {
System.out.println("want to open an account? 1.Yes 2.No");
Scanner sc = new Scanner(System.in);
int choice;
choice=sc.nextInt();
String typeOfDecision;
if(choice==1) {
typeOfDecision="Yes";
Customerone cone=new Customerone();
System.out.println("Enter your Name:");
sc.nextLine();
cone.setName(sc.nextLine());
System.out.println("Which type of account? 1.Savings account 2.Current Account");
sc.nextLine();
cone.setTypeOfAccount(sc.nextLine());
System.out.println("Enter Date of Birth:");
sc.nextLine();
cone.setDob(sc.nextLine());
System.out.println("Which bank you want? 1.SBI 2.ICICI 3.PNB");
sc.nextLine();
cone.setTypeOfBank(sc.nextLine());
if(cone.confirmUser()==true) {
System.out.println("Account has been opened and account number is:123");
}
SBI sbi=new SBI();
System.out.println("Which bank we want to access 1.SBI 2.ICICI 3.PNB");
sc.nextLine();
sbi.setWhichbankweaccess(sc.nextLine());
System.out.println("What type of account you have? 1.Savings account 2.Current account");
sc.nextLine();
cone.setTypeOfAccount(sc.nextLine());
System.out.println("Which user account we want to access 1.User1 2.User2");
sc.nextLine();
cone.setUser1(sc.nextLine());
sbi.setMinSavingsAccount(2000);
System.out.println("Minimum account for Savings account= " +sbi.getMinSavingsAccount());
sbi.setMinCurrentAccount(5000);
System.out.println("Minimum account for Current account= " +sbi.getMinCurrentAccount());
sbi.setFa(20000);
System.out.println("Your final account is= " + sbi.getFa());
sbi.setIpb(3000);
System.out.println("Your initial principal amount is= " + sbi.getIpb());
sbi.setMininterestsavings(0.05);
System.out.println("Interest rates for savings= " + sbi.getMininterestsavings());
sbi.setMininterestcurrent(0.08);
System.out.println("Interest rates for current= " + sbi.getMininterestcurrent());
System.out.println("How many years you want to calculate interest?");
sc.nextLine();
sbi.setYears(sc.nextLine());
System.out.println("Your interest calculated years is= "+ sbi.getYears());
}
}
}
abstract class User {
String name;
String typeOfAccount;
String dob;
String typeOfBank;
String user1;
public String getUser1() {
return user1;
}
public void setUser1(String user1) {
this.user1 = user1;
}
public String getUser2() {
return user2;
}
public void setUser2(String user2) {
this.user2 = user2;
}
String user2;
abstract Boolean confirmUser();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTypeOfAccount() {
return typeOfAccount;
}
public void setTypeOfAccount(String typeOfAccount) {
this.typeOfAccount = typeOfAccount;
}
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public String getTypeOfBank() {
return typeOfBank;
}
public void setTypeOfBank(String typeOfBank) {
this.typeOfBank = typeOfBank;
}
}
class Customerone extends User {
public Boolean confirmUser() {
return true;
}
}
class Account {
// String user1;
// String user2;
int savingsAccount;
int currentAccount;
public int getSavingsAccount() {
return savingsAccount;
}
public void setSavingsAccount(int savingsAccount) {
this.savingsAccount = savingsAccount;
}
public int getCurrentAccount() {
return currentAccount;
}
public void setCurrentAccount(int currentAccount) {
this.currentAccount = currentAccount;
}
}
class RBI {
String whichBankWeAccess;
public float getSimpleinterest() {
return simpleinterest;
}
public void setSimpleinterest(float simpleinterest) {
this.simpleinterest = simpleinterest;
// this.fa=ipb*(1+air*years);
}
int minSavingsAccount;
double fa;
double ipb;
float air;
String years;
double mininterestsavings;
double mininterestcurrent;
float simpleinterest;
public float getCompoundinterest() {
return compoundinterest;
}
public void setCompoundinterest(float compoundinterest) {
this.compoundinterest = compoundinterest;
}
public void setIpb(double ipb) {
this.ipb = ipb;
}
float compoundinterest;
public double getMininterestsavings() {
return mininterestsavings;
}
public void setMininterestsavings(double mininterestsavings) {
this.mininterestsavings = mininterestsavings;
}
public double getMininterestcurrent() {
return mininterestcurrent;
}
public void setMininterestcurrent(double mininterestcurrent) {
this.mininterestcurrent = mininterestcurrent;
}
public String getWhichBankWeAccess() {
return whichBankWeAccess;
}
public void setWhichBankWeAccess(String whichBankWeAccess) {
this.whichBankWeAccess = whichBankWeAccess;
}
public double getFa() {
return fa;
}
public void setFa(double fa) {
this.fa = fa;
}
public double getIpb() {
return ipb;
}
public void setIpb(int ipb) {
this.ipb = ipb;
}
public float getAir() {
return air;
}
public void setAir(float air) {
// fa=ipb*(1+(this.Integer.parseInt(years)*air));
this.air = air;
air=(float) (ipb*(1+(air*2)));
}
public void setAir0ne() {
}
public String getYears() {
return years;
}
public void setYears(String years) {
this.years = years;
}
public int getMinSavingsAccount() {
return minSavingsAccount;
}
public void setMinSavingsAccount(int minSavingsAccount) {
this.minSavingsAccount = minSavingsAccount;
}
public int getMinCurrentAccount() {
return minCurrentAccount;
}
public void setMinCurrentAccount(int minCurrentAccount) {
this.minCurrentAccount = minCurrentAccount;
}
int minCurrentAccount;
public String getWhichbankweaccess() {
return whichBankWeAccess;
}
public void setWhichbankweaccess(String whichbankweaccess) {
this.whichBankWeAccess = whichbankweaccess;
}
}
class SBI extends RBI {
String whichBankWeAccess;
}
class ICICI extends RBI {
String whichbankweaccess;
}
class PNB extends RBI {
String whichbankweaccess;
}
OUTPUT
want to open an account? 1.Yes 2.No
1
Enter your Name:
karthikeyan
Which type of account? 1.Savings account 2.Current Account
1
Enter Date of Birth:
22 11 1988
Which bank you want? 1.SBI 2.ICICI 3.PNB
1
Account has been opened and account number is:123
Which bank we want to access 1.SBI 2.ICICI 3.PNB
1
What type of account you have? 1.Savings account 2.Current account
1
Which user account we want to access 1.User1 2.User2
1
Minimum account for Savings account= 2000
Minimum account for Current account= 5000
Your final account is= 20000.0
Your initial principal amount is= 3000.0
Interest rates for savings= 0.05
Interest rates for current= 0.08
How many years you want to calculate interest?
3
Your interest calculated years is=
------------------------------------------------------==========================---------------------------------------