Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class BankAccount{
- static String name;
- static int type;
- static long balance;
- static double ac_no;
- static void assign(){
- name = "XYX ABC";
- type = 1;
- balance = 1000;
- ac_no = 432984123;
- }
- static long deposit(long n){
- return n+balance;
- }
- static long withdraw(long n){
- if(n>balance) System.out.println("The balance is too low.");
- else return balance - n;
- return balance;
- }
- static void display(){
- System.out.println("\tName\tBalance");
- System.out.print("\t"+name+"\t"+balance);
- }
- public static void main(String [] args){
- Scanner sc = new Scanner(System.in);
- assign();
- while(true){
- System.out.print("\n1.Deposit 2. Withdraw 3.View Details 4.Exit: ");
- int n = sc.nextInt();
- switch(n){
- case 1: System.out.print("Enter the amount to deposit: ");
- balance = deposit(sc.nextLong());
- break;
- case 2: System.out.print("Enter the amount to withdraw: ");
- balance = withdraw(sc.nextLong());
- break;
- case 3: display();
- break;
- case 4: return;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment