⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bankaccount.java

📁 This will simulate a bank account and utilize different techniques.
💻 JAVA
字号:
//
//
//

public class BankAccount
{
	private static final double interest = .04;
	private double balance;
	private static int account=100;

	public BankAccount()
	{
		setBalance();
		account++;
	}

	public BankAccount(double bl)
	{
		balance = bl;
		account++;
	}

	private void setBalance()
	{
		balance = ((int)(Math.random()*100000))/100.0;
	}

	public String deposit(double d)
	{
		if(d<=0)
		{
			return "Deposit Rejected";
		}
		else
		{
			balance+=d;
			return "Deposit Accepted";
		}
	}

	public String withdraw(double w)
	{
		if(balance-w<0)
		{
			return "Withdraw Rejected - Insufficient Funds";
		}
		else
		{
			balance-=w;
			return "Withdraw Accepted";
		}
	}

	public double calcInterest()
	{
		balance=balance+(balance*interest);
		return balance;
	}

	public int getAccount()
	{
		return account;
	}

	public double getBalance()
	{
		return balance;
	}

	public static double getInterest()
	{
		return 100*interest;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -