Preview:
BankAccount.java

import java.util.Scanner;

public class BankAccount {
    String name;
	private double balance;
	private int depositCount = 0;
	private int withdrawCount = 0;
	
	public void deposit(double amount){
		balance += amount;
		System.out.println(amount + " is successfully Deposited");
		depositCount++;
		if(balance > 100000){
			balance = balance + (amount / 100);
		}
	}
	public void withdraw(double amount){
		if(balance >= amount){
			if(balance - amount < 50000){
				System.out.println("Asre you sure you want to withdraw, it would make your balance below 50,000");
				System.out.println("Press 1 to continue and 0 to abort");
				Scanner input = new Scanner(System.in);
				int confirm = input.nextInt();
				if(confirm != 1){
					System.out.println("Withdrawal aborted");
					return;
				}
			}
			double withdrawAmount = amount;
			if(balance < 50000){
				withdrawAmount = withdrawAmount + amount * 0.02;
				withdrawCount++;
			}
			balance = balance - withdrawAmount;
			System.out.println(withdrawAmount + " is successfully withdrawn");
			
		}
		else{
			System.out.println("Insufficient funds");
		}
			
	}
	public double getBalance(){
		return balance;
	}
	void transaction(){
		System.out.println("Account title: " + name);
		System.out.println("Total deposit: " + depositCount);
		System.out.println("Total withdraw: " + withdrawCount);
		System.out.println("Balance: " + balance);
	}
	
}

///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////

BankAccountTest.java

import java.util.Scanner;

public class BankAccountTest{
	
	public static void main(String args[]){
		
		BankAccount account = new BankAccount();
		
		Scanner input = new Scanner(System.in);
		account.name = "Maan";
		
		int choice;
		
		do{
			System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program");
		    choice = input.nextInt();
		
		    switch(choice){
			case 1:
			System.out.println("Enter the amount you want to Deposite");
			double depositeAmount = input.nextDouble(); 
			account.deposit(depositeAmount);
			break;
			case 2:
			System.out.println("Enter the amount you want to withdraw");
			double withdrawAmount = input.nextDouble();
			account.withdraw(withdrawAmount);
			break;
			case 3:
			System.out.println("Your current balance is " + account.getBalance());
			break;
			case 4:
			System.out.println("The program is terminated");
			account.transaction();
			break;
			default:
			System.out.println("Incorrect choice. Please try again!");
			break;
			
		
		}
		
	}while(choice!=4);
  }
	
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter