All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
CHALLENGE-10 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…
Paul Selvi
updated on 29 Jan 2023
CHALLENGE-10
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 raate 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:
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 |
Hint:
Class Customer
{
//Personal Details ...
// Few functions ...
}
Class Account
{
// Account Detail ...
// Few functions ...
}
Class RBI
{
Customer c; //hasA relationship
Account a; //hasA relationship
..
Public double GetInterestRate() { }
Public double GetWithdrawalLimit() { }
}
Class SBI: public RBI
{
//Use RBI functionality or define own functionality.
}
Class ICICI: public RBI
{
//Use RBI functionality or define own functionality.
}
PROGRAM:
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Random;
class Customer
{
private int accno;
private String name;
private String acc_type;
private long balance;
private String dob;
Scanner sc = new Scanner(System.in);
//method to open new account
public void openAccount()
{
System.out.print("\nEnter your name: ");
name = sc.next();
System.out.print("Enter your Account type: ");
acc_type = sc.next();
System.out.print("Enter your date of birth: ");
dob = sc.next();
//create account number
Random rand = new Random();
accno = rand.nextInt(10000);
System.out.print("Account has been opened successfully!!"+"\n Your account number is:"+accno);
Account A= new Account();
A.showAccount();
int choi;
System.out.println("1. Saving Account \n 2. Current Account\n 3.Exit ");
System.out.println("Enter your choice: ");
choi = sc.nextInt();
switch (choi) {
case 1:
System.out.print("\n Account type is:"+acc_type+"\n");
RBI SI= new RBI();
SI.simpleinterest();
case 2:
System.out.print("\n Account type is:"+acc_type+"\n");
RBI CI= new RBI();
CI.compoundinterest();
case 3:
break;
}
}
class Account{
//method to display account details
public void showAccount() {
System.out.println("\nAccount Details");
System.out.println("\nName of account holder: " + name);
System.out.println("Account no.: " + accno);
System.out.println("Account type: " + acc_type);
System.out.println("Date of Birth: " + dob);
System.out.println("Balance: " + balance);
}
}
class RBI{ // Base class
int withLimit;
public void simpleinterest() {
double P, r, t, s_interest,A,totint,minbal;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the value of Principal:");
P = scanner.nextDouble();
r=5;
System. out. print("Enter the Time (years):");
t = scanner.nextDouble();
s_interest = (P * r * t)/100;
System.out.println("Simple Interest: "+s_interest);
A = P * (1+(r * t));
System.out.println("Total Amount on Simple Interest: "+A);
totint=A-P;
System.out.println("Total Interest: "+totint);
minbal=2000;
System.out.println("Minimum Balance: "+minbal);
SBI sbi = new SBI();
int sbiWL= sbi.setWithdrawalLimit();
System.out.println("SBI withdraw limit is:"+sbiWL);
ICICI icici = new ICICI();
int iciciWL= icici.setWithdrawalLimit();
System.out.println("ICICI withdraw limit is:"+iciciWL);
PNB pnb = new PNB();
int pnbWL= pnb.setWithdrawalLimit();
System.out.println("PNB withdraw limit is:"+pnbWL);
File file = new File("E:\\Skilllync\\Introduction to JAVA\\Challenge-10\\CHALLENGE-10\\simpleinterest.txt");
PrintWriter printWriter = null;
try
{
printWriter = new PrintWriter(file);
printWriter.println("Simple Interest: "+s_interest);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
finally
{
if ( printWriter != null )
{
printWriter.close();
}
}
}
public void compoundinterest() {
double A,P, r,nc,t,c_interest,totintst,minibal;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the value of Principal:");
P = scanner.nextDouble();
//System. out. print("Enter the Annual Rate of Interest:");
//r = scanner.nextDouble();
r=8;
nc=2;
System. out. print("Enter the Time (years):");
t = scanner.nextDouble();
c_interest = P * Math.pow(1.0+r/100.0,t) - P;
System.out. println("Compound Interest: "+c_interest);
A = P * (1+(r * nc))*(nc*t);
System.out.println("Total Amount on Compound Interest: "+A);
minibal=5000;
System.out.println("Minimum Balance: "+minibal);
File file = new File("E:\\Skilllync\\Introduction to JAVA\\Challenge-10\\ CHALLENGE-10\\compoundinterest.txt");
PrintWriter printWriter = null;
try
{
printWriter = new PrintWriter(file);
printWriter.println("Compound Interest: "+c_interest);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
finally
{
if ( printWriter != null )
{
printWriter.close();
}
}
}
}
class SBI extends RBI{ // derived class1
int setWithdrawalLimit() {
withLimit=10000;
return withLimit;
}
}
class ICICI extends RBI{ // derived class2
int setWithdrawalLimit() {
withLimit=15000;
return withLimit;
}
}
class PNB extends RBI{ // derived class1
int setWithdrawalLimit() {
withLimit=20000;
return withLimit;
}
}
}
public class BankingApp {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int choice;
do {
Scanner sc1 = new Scanner(System.in);
System.out.print("Do you want to open an account?(Y/N)");
choice = sc1.next().charAt(0);
//Select Bank
System.out.print("In which bank, do you want to open an account:");
int ch1;
System.out.println("1. SBI Bank \n 2. ICICI Bank\n 3. PNB Bank \n 4.Exit ");
System.out.println("Enter your choice: ");
ch1 = sc.nextInt();
switch (ch1) {
case 1:
System.out.print("SBI Bank\n");
System.out.print("How many number of customers do you want to input? ");
//create customer
Scanner sc2 = new Scanner(System.in);
int n = sc2.nextInt();
Customer C[] = new Customer[n];
for (int i = 0; i < C.length; i++) {
C[i] = new Customer();
C[i].openAccount();
}
break;
case 2:
System.out.print("ICICI Bank\n");
System.out.print("How many number of customers do you want to input? ");
//create customer
Scanner sc3 = new Scanner(System.in);
int n1 = sc3.nextInt();
Customer C1[] = new Customer[n1];
for (int i = 0; i < C1.length; i++) {
C1[i] = new Customer();
C1[i].openAccount();
}
break;
case 3:
System.out.print("PNB Bank\n");
System.out.print("How many number of customers do you want to input? ");
//create customer
Scanner sc4 = new Scanner(System.in);
int n2 = sc4.nextInt();
Customer C2[] = new Customer[n2];
for (int i = 0; i < C2.length; i++) {
C2[i] = new Customer();
C2[i].openAccount();
}
break;
case 4:
break;
}
}
while(choice == 'Y'|| choice == 'y');
}
}
OUTPUT:
Do you want to open an account?(Y/N)Y
In which bank, do you want to open an account:1. SBI Bank
4.Exit
Enter your choice:
1
SBI Bank
How many number of customers do you want to input? 1
Enter your name: PAUL
Enter your Account type: SAVING
Enter your date of birth: 12.02.2003
Account has been opened successfully!!
Your account number is:1344
Account Details
Name of account holder: PAUL
Account no.: 1344
Account type: SAVING
Date of Birth: 12.02.2003
Balance: 0
3.Exit
Enter your choice:
1
Account type is:SAVING
Enter the value of Principal:
2000
Enter the Time (years):3
Simple Interest: 300.0
Total Amount on Simple Interest: 32000.0
Total Interest: 30000.0
Minimum Balance: 2000.0
SBI withdraw limit is:10000
ICICI withdraw limit is:15000
PNB withdraw limit is:20000
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2 - Shopping cart application
Shopping Cart Application
05 Mar 2023 09:51 AM IST
Project 1 - Expense tracker
Expense tracker application
01 Mar 2023 04:44 PM IST
Project 2
CHALLENGE-10 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…
29 Jan 2023 12:06 PM IST
Project 1
ecommerce project file attached below.Please find my attachment.
18 Jan 2023 05:53 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.