Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- abstract class BankAccount
- {
- private String name;
- private String type;
- private String accountnum;
- private double balance;
- BankAccount(String nam,String actype,String num,double blnce)
- {
- name=nam;
- type=actype;
- num=accountnum;
- balance=blnce;
- }
- void depositamount(double amount)
- {
- balance+=amount;
- }
- void withdrawamount(double amount)
- {
- if(balance<amount)
- {
- System.out.println("Not Enough Balance");
- }
- else
- {
- System.out.println(+ amount +" is Withdrawn");
- balance-=amount;
- }
- }
- void Savings_deposit(int year)
- {
- double value=balance;
- for(int i=1;i<=year;i++)
- {
- value=value*(1.0+1/100);
- }
- balance=value;
- }
- void Fixed_Deposit(int year)
- {
- double value=balance;
- for(int i=1;i<=year;i++)
- {
- value=value*(1.0+1/100);
- }
- setbalance(value);
- }
- void displayNameAndBalance()
- {
- System.out.println("Name "+name);
- System.out.println("Account Type "+type);
- System.out.println("Account No "+accountnum);
- System.out.println("Balance "+balance);
- }
- double getbalance()
- {
- return balance;
- }
- void setbalance(double value)
- {
- balance=value;
- //System.out.println("AA "+balance);
- }
- String getName()
- {
- return name;
- }
- }
- class SonaliBank extends BankAccount{
- SonaliBank(String nam,String type,String accno,double blnce)
- {
- super(nam,type,accno,blnce);
- }
- void Fixed_Deposit(int year)
- {
- double value=getbalance();
- for(int i=1;i<=year;i++)
- {
- value=value+(value*2.0/100);
- }
- setbalance(value);
- }
- void displayNameAndBalance()
- {
- System.out.println("Sonali bank ");
- System.out.println("Name : " + getName());
- System.out.println("Balance : " + getbalance());
- }
- }
- class AgraniBank extends BankAccount{
- AgraniBank(String nam,String type,String accno,double blnce)
- {
- super(nam,type,accno,blnce);
- }
- void Fixed_Deposit(int year)
- {
- double value=getbalance();
- for(int i=1;i<=year;i++)
- {
- value=value+value*(3.0/100.0);
- }
- setbalance(value);
- }
- void displayNameAndBalance()
- {
- System.out.println("Agrani Bank ");
- System.out.println("Name : " + getName());
- System.out.println("Balance : " + getbalance());
- }
- }
- class JanataBank extends BankAccount{
- JanataBank(String nam,String type,String accno,double blnce)
- {
- super(nam,type,accno,blnce);
- }
- void Fixed_Deposit(int year)
- {
- double value=getbalance();
- for(int i=1;i<=year;i++)
- {
- value+=value*(2.5/100.0);
- }
- setbalance(value);
- }
- void displayNameAndBalance()
- {
- System.out.println("Janata Bank ");
- System.out.println("Name : " + getName());
- System.out.println("Balance : " + getbalance());
- }
- }
- public class BankingSystem {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- while(true)
- {
- System.out.println("Enter the Bank ");
- System.out.println("1.Sonali Bank ");
- System.out.println("2.Agrani Bank ");
- System.out.println("Janata bank ");
- int choice;
- choice = input.nextInt();
- String nam,accno;
- int acctype;
- double balance=0.0;
- System.out.println("Enter the Name of Account");
- nam=input.next();
- System.out.println("Enter the type of Account");
- System.out.println("1.Fixed Deposit");
- System.out.println("2.Savings");
- acctype=input.nextInt();
- System.out.println("Enter the No of Account");
- accno=input.next();
- System.out.println("Enter balance");
- balance=input.nextDouble();
- if(choice==1)
- {
- String type;
- if(acctype==1)
- {
- type="Fixed";
- }
- else
- type="Savings";
- BankAccount s;
- s=new SonaliBank(nam,type,accno,balance);
- System.out.println("Balance "+s.getbalance());
- System.out.println("Want to Depost or Withdraw");
- System.out.println("1.Deposit");
- System.out.println("2.Withdraw");
- int z=input.nextInt();
- if(z==1)
- {
- System.out.println("Enter the Time to to Deposit");
- int x;
- x=input.nextInt();
- if(acctype==1)
- {
- s.Fixed_Deposit(x);
- }
- else
- {
- s.Savings_deposit(x);
- }
- }
- else
- {
- int x;
- System.out.println("Enter the amount to withdraw");
- x=input.nextInt();
- s.withdrawamount(x);
- }
- s.displayNameAndBalance();
- }
- else if(choice==2)
- {
- String type;
- if(acctype==1)
- {
- type="Fixed";
- }
- else
- type="Savings";
- BankAccount ag=new AgraniBank(nam,type,accno,balance);
- System.out.println("Balance "+ag.getbalance());
- System.out.println("Want to Depost or Withdraw");
- System.out.println("1.Deposit");
- System.out.println("2.Withdraw");
- int z=input.nextInt();
- if(z==1)
- {
- System.out.println("Enter the Time to to Deposit");
- int x;
- x=input.nextInt();
- if(acctype==1)
- {
- ag.Fixed_Deposit(x);
- }
- else
- {
- ag.Savings_deposit(x);
- }
- }
- else
- {
- int x;
- System.out.println("Enter the amount to withdraw");
- x=input.nextInt();
- ag.withdrawamount(x);
- }
- ag.displayNameAndBalance();
- }
- else if(choice==3)
- {
- String type;
- if(acctype==1)
- {
- type="Fixed";
- }
- else
- type="Savings";
- BankAccount jb=new JanataBank(nam,type,accno,balance);
- System.out.println("Balance "+jb.getbalance());
- System.out.println("Want to Depost or Withdraw");
- System.out.println("1.Deposit");
- System.out.println("2.Withdraw");
- int z=input.nextInt();
- if(z==1)
- {
- System.out.println("Enter the Time to to Deposit");
- int x;
- x=input.nextInt();
- if(acctype==1)
- {
- jb.Fixed_Deposit(x);
- // System.out.println("X "+value);
- }
- else
- {
- jb.Savings_deposit(x);
- }
- }
- else
- {
- int x;
- System.out.println("Enter the amount to withdraw");
- x=input.nextInt();
- jb.withdrawamount(x);
- }
- jb.displayNameAndBalance();
- }
- System.out.println("DO U want to check again");
- System.out.println("1.YES");
- System.out.println("2.No");
- int check;
- check=input.nextInt();
- if(check==2)
- {
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment