Untitled

mail@pastecode.io avatar
unknown
java
a year ago
2.1 kB
29
Indexable
Never


// yahan se app class ko paste karna (agar copy karrahe ho, aur agar nahi karrahe ho tou achi baat hai, thanks)

package task1;

public class AppClass {
    public static void main(String[] args) {
        BankAccount b = new BankAccount();
        Scanner sc = new Scanner(System.in);
        

        
        String cont;
        int choice;
        
        do {
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.flush();
        System.out.println("\t \t \t 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");
        System.out.println("Press 4 to exit");
        
        choice = sc.nextInt();
        
            switch (choice) {
                case 1:
                    b.deposit(sc.nextDouble());
                    break;
                case 2:
                    b.widthdraw(sc.nextDouble());
                    break;
                case 3:
                    System.out.println("Your balance is : " + b.getBalance());
                    break;
                default:
                    break;
            }

        
            
            System.out.println("Do you want to continue?");
            cont = sc.next();
           
        } while(cont.equalsIgnoreCase("yes"));
        
            
        
        
    }
}

// yahan se bankaccount wali class hai
package task1;

/**
 *
 * @author HP
 */
public class BankAccount {
    private double balance;
    
    public void deposit(double amount) {
        balance = balance + amount;
    }
    
    public void widthdraw(double amount) {
        balance = balance - amount;
    }
    
    public double getBalance() {
        return balance;
    }
}