Challenge

Project 2

Project 2-banking management system

  • 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.
import java.util.Scanner;
import java.lang.Math;
import java.io.*;

public class RBI {
public static void main(String[] args) {

System.out.println("*******Welcome to National Banking System*********");
System.out.println("n");
System.out.println("Do you want to open an account(Enter Yes or No): 1. Yes 2. No");

Scanner sc = new Scanner(System.in);
String choice = sc.nextLine();

if (choice.equalsIgnoreCase("Yes")) {
OpenAccount obj = new OpenAccount();
obj.CreateAccount();
}

if (choice.equalsIgnoreCase("No")) {
BankAccount obj1 = new BankAccount();
obj1.showMenu();
}
}
}

class OpenAccount {
String name;
int accountNum ;
String accountType;
String dob;
String bank;

void CreateAccount() {
Scanner sc = new Scanner(System.in);

System.out.println("In which bank you want to open it: 1.SBI 2.PNB 3.ICICI");
int choiceBank = sc.nextInt();
if (choiceBank == 1) {
bank = "SBI";
}
if (choiceBank == 2) {
bank = "PNB";
}
if (choiceBank == 3) {
bank = "ICICI";
}

System.out.println("Please enter your name: ");
sc.nextLine();
name = sc.nextLine();

System.out.println("Please enter your date of birth: ");
dob = sc.nextLine();

System.out.println("What type of account you want to open: 1. Saving 2. Current");
int choice = sc.nextInt();
if (choice == 1) {
accountType = "Saving";
}
if (choice == 2) {
accountType = "Current";
}

System.out.println("Your account has been opened with following details");
System.out.println("Bank: " + bank);
System.out.println("Name: " + name);
System.out.println("DOB: " + dob);
System.out.println("Account Type: " + accountType);
System.out.println("Account Number:" +Math.random() );

System.out.println("n");

BankAccount obj1 = new BankAccount();
obj1.showMenu();
sc.close();
}
}

class BankAccount {
int balance;
int previousTransaction;
String customerName;
String customerId;
String accountType;
double totalInterest;

void calulateInterest(double balance) {
System.out.println("What type of account you have: 1. Saving 2. Current");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();

if (choice == 1) {
accountType = "Saving";
int r = 5;
int t;
System.out.println("Enter year to calculate interest");
t = sc.nextInt();

double finalAmount = balance * (1 + r * t);

totalInterest = finalAmount - balance;
System.out.println("Total interest earned is: " + totalInterest);

}
if (choice == 2) {
accountType = "Current";
int r = 8;
int t, n;
System.out.println("Enter year to calculate interest");
t = sc.nextInt();
System.out.println("Enter the frequency that interest has been compound in a year");

n = sc.nextInt();

double finalAmount = balance * (Math.pow((1 + r / n), n * t));

totalInterest = finalAmount - balance;
System.out.println("Total interest earned is: " + totalInterest);
sc.close();
}
}

void deposit(int amount) {
if (amount != 0)
;
{
balance = balance + amount;
System.out.println("Balance after deposit: " + balance);
previousTransaction = amount;
}
}

void withdraw(int amount) {
if (amount != 0)
;
{
balance = balance - amount;
System.out.println("Balance after withdraw: " + balance);
previousTransaction = -amount;
}
}




void showMenu() {
char option = '�';
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome to the menu");
System.out.println("n");
System.out.println("A. Check Balance");
System.out.println("B. Deposit Amount");
System.out.println("C. Withdraw amount");
System.out.println("D. See Previous transaction");
System.out.println("E. Calculate Interest");
System.out.println("F. Exit");

do {
System.out.println("================#*#===============");
System.out.println("Enter an option(A, B, C, D, E, F)");
System.out.println("================#*#===============");
option = scanner.next().charAt(0);
System.out.println("n");

switch (option) {
case 'A':
System.out.println("------------------------------");
System.out.println("Balance = " + balance);
System.out.println("n");
break;

case 'B':
System.out.println("------------------------------");
System.out.println("Enter an amount to deposit: ");
int amount = scanner.nextInt();
deposit(amount);
System.out.println("n");
break;

case 'C':
System.out.println("------------------------------");
System.out.println("Enter an amount to withdraw");
int amount2 = scanner.nextInt();
withdraw(amount2);
System.out.println("n");
break;

case 'D':
System.out.println("------------------------------");

System.out.println("n");
break;

case 'E':
System.out.println("------------------------------");
calulateInterest(balance);
System.out.println("n");
break;

case 'F':
System.out.println("---------------------");
break;

default:
System.out.println("Entered Invalid option!. Please enter Again");
break;
}
} while (option != 'F');
System.out.println("Thank you for using our services");
scanner.close();
}
}
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.