0% found this document useful (0 votes)
50 views4 pages

sp20bscs0030 Assignment 01

This document contains code for a banking application with classes for Bank, Customer, CurrentAccount, SavingAccount, and FixedDepositAccount. A Main class is used to test the application by creating a Bank and Customer object, setting account details, and performing deposit and withdraw transactions based on the account type. Transactions are processed differently for current and saving accounts, with withdrawals checking the available balance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

sp20bscs0030 Assignment 01

This document contains code for a banking application with classes for Bank, Customer, CurrentAccount, SavingAccount, and FixedDepositAccount. A Main class is used to test the application by creating a Bank and Customer object, setting account details, and performing deposit and withdraw transactions based on the account type. Transactions are processed differently for current and saving accounts, with withdrawals checking the available balance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Raja Izhan Abbasi

ID: SP20BSCS0030
Section: BM
 
 
 
import java.util.Scanner;
class Bank{
    
    Scanner s1=new Scanner(System.in);
    
    protected String accountTitle;
    protected int accountNumber;
    protected float Amount;
    protected String accountType;
    
    public Bank(){
        
    }
    
    protected String getaccountTitle(){
        return accountTitle;
    }
    
    protected int getaccountNumber(){
        return accountNumber;
    }
    
    protected float getAmount(){
        return Amount;
    }
    
    protected void setaccountTitle(String accountTitle){
        this.accountTitle=accountTitle;
    }
    
    protected void setaccountNumber(int accountNumber){
        this.accountNumber=accountNumber;
    }
    
    protected void setAmount(float Amount){
        this.Amount=Amount;
    }
    
    
    
    protected void Deposit(float Amount){
        this.Amount+=Amount;
        System.out.println("Amount successfully Deposited");
    }
    
    
}
 
class Customer extends Bank {
    protected String customerName;
    protected String customerEmail;
    protected String customerNumber;
    
    public Customer(String customerName,String customerEmail,String customerNumber){
        super();
        this.customerName=customerName;
        this.customerEmail=customerEmail;
        this.customerNumber=customerNumber; 
    }
    
    protected String getcustomerName(){
        return customerName;
    }
    
    protected String getcustomerEmail(){
        return customerEmail;
    }
    
    protected String getcustomerNumber(){
        return customerNumber;
    }
    
    protected void setaccountType(){
        System.out.print("Enter Your Account Type: ");
        this.accountType=s1.nextLine();
    }
    
    protected String getaccountType(){
        return this.accountType;
    }
    
}
 
class currentAccount extends Bank{
    
    
    public void Withdraw(float Am){
      
        if(this.Amount>0){
            if(this.Amount<Am){
              System.out.println("Your Account doesn't have enough money");
            }
            else{
              this.Amount-=Am;
              System.out.println("Withdraw request successfully completed!");
            }
           
        }
        else{
           System.out.println("Amount can't be negative or zero while processing withdraw
request");
            
        }
    }
    
     
}
 
class savingAccount extends Bank{
         
}
 
class fixedDepositAccount extends Bank{
    }
    
     
}

import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
    Scanner s1=new Scanner(System.in);
    Bank b1=new Bank();
         b1.setaccountNumber(343434);
         b1.setaccountTitle("Raja ");
         
         Customer c1=new Customer("Raja","[email protected]","0330220520");
         c1.setaccountType();
         String Type=c1.getaccountType();
 
         if(Type.equals("Current")){
             currentAccount ca=new currentAccount();
             ca.Deposit(2000);
             ca.Withdraw(5000);
         }
         else if(Type.equals("Saving")){
            savingAccount sa=new savingAccount();
             sa.setAmount(5000);
             
             sa.Withdraw(5000);
         }
 }

You might also like