Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
1
Indexable
Never

package oopassignment;

import java.util.Scanner;


public class OOPAssignment {

    public static void main(String[] args) {
        applicationclass a=new applicationclass();
        Scanner sc=new Scanner(System.in);
        System.out.println("Bank management System");
        System.out.println("***************************");
        System.out.println("Enter your choice");
        System.out.println("Press 1 to deposit");
        System.out.println("Press 2 to withdraw");
        System.out.println("Press 3 to get balance");
        int ch;
        String co="yes";
        do {
        ch=sc.nextInt();
        switch (ch) {
            case 1:
                a.deposit(sc.nextDouble());
                break;
            case 2:
                a.withdraw(sc.nextDouble());
                break;
            case 3:
                System.out.println("Your balance is "+a.getbalance());
                break;
            default:
                break;
        }
        System.out.println("Do you wish to continue.");
        }while(co=="yes");
    }
}

//application class

package oopassignment;


public class applicationclass {
    private double balance;
    public void deposit(double amount)
    {
        balance=balance+amount;
        
    }
    public void withdraw(double amount)
    {
        balance=balance-amount;
        
    }
    public double getbalance()
    {
        
        return balance;
        
    }
    
}