Account.java

                Never    
Java
       
package com;
import java.util.Scanner;

public class Account {
	
	private String accno;
	private String name;
	private String balance;
	private double bal;
	Scanner sc = new Scanner(System.in);

	void openAccount() {

		for (int i = 1; i > 0; i++) {
			
			System.out.print("Enter Account No: ");
			accno = sc.next();
			
			int l = accno.length();
			
			if (l == 10 && isNumeric(accno)) {

				System.out.print("Enter Name: ");
				name = sc.next();
				System.out.print("Enter Balance: ");
				for(int j=1;j>0;j++) {
					balance = sc.next();
					if(Account.isDigit(balance)) {
						bal = Long.parseLong(balance);
						break;
					}
					else 
						continue;
				}
				
				break;
			}
			else {
				System.out.println("Enter Valid account number");
				continue;
			}
		}
	}
	public static boolean isDigit(String n) {
		try {
			double i = Double.parseDouble(n);

		} catch(NumberFormatException e) {
			System.out.println("Enter a valid input: ");
			return false;
		}
		return true;
	}
	public static boolean isNumeric(String strNum) {

		try {

			double d = Double.parseDouble(strNum);

		} catch (NumberFormatException | NullPointerException nfe) {

			return false;
		}
		return true;
	}
	
	void showAccount() {
		System.out.println("Account no:" + accno + "\n" + "Customer Name:" + name + "\n" + "Account Balance:" + bal);
	}

	void deposit() {
		double amount=0;
		String amt;
		System.out.println("Enter Amount U Want to Deposit : ");
		
		for(int j=1;j>0;j++) {
			
			amt = sc.next();
			if(isDigit(amt)) {
				amount = Double.parseDouble(amt);
				break;
			}
			else 
				continue;
		}
		
		bal = bal + amount;
		System.out.println("Total Balance: "+bal);
		showAccount();
	}

	void withdrawal() {

		double amount=0;
		String amt;
		System.out.println("Enter Amount U Want to withdraw : ");
		
		for(int j=1;j>0;j++) {
			
			amt = sc.next();
			if(isDigit(amt)) {
				amount = Double.parseDouble(amt);
				break;
			}
			else 
				continue;
		}
		
		if (bal >= amount) {

			bal = bal - amount;
			showAccount();
		}
		else {
			System.out.println("Less Balance..Transaction Failed..");
		}
	}

	boolean search(String acn) {

		if (accno.equals(acn)) {

			showAccount();
			return (true);
		}
		return (false);
	}
}

Raw Text