I'm new to JAVA and I can't seem to get this thing down I might be totally off. But I need to do a withdraw and deposit method any ideas??

public class Account {
	private int id;
	private double balance;
	private double annualInterestRate;
	private double withdraw;
	private double deposit;
	private double withdrawTotal;
	private double depositTotal;
//----------------------------------------
// Default constructor
//----------------------------------------

	Account()
	{
		id = 0;
		balance = 0;
		annualInterestRate = 0;
		withdraw = 0;
		deposit = 0;
	}	

//---------------------------------------
// Accessor method
//---------------------------------------

	public int getId() {
		return id;
	}
	
	public double getBalance(){
		return balance;
	}
	
	public double getAnnualInterestRate(){
		return annualInterestRate;
	}
	
	public double getWithdraw() {
		return withdraw;
	}
	
	public double getDeposit() {
		return deposit;
	}
	
	public double getWithdrawTotal() {
		return withdrawTotal;
	}
	
	public double getDepositTotal() {
		return depositTotal;
	}
//------------------------------------------
// Mutator methods
//------------------------------------------

	public void setId(int newId){
		id = newId;
	}
	
	public void setBalance(double newBalance){
		balance = newBalance;
	}
	
	public void setAnnualInterestRate(double newAnnualInterestRate){
		annualInterestRate = newAnnualInterestRate;
	}
	
	public void setWithdraw(double newWithdraw){
		withdraw = newWithdraw;
	}
//-------------------------------------------
// Withdraw method
//-------------------------------------------

	public double withdrawCalculuation() {
		return balance - withdraw;
	}
	
	public double depositCalculation(){
		return balance + deposit;
	}
	
	public double annualInterestRateCalculation(){
		return depositTotal * .045;
	}
	
//--------------------------------------------
// void method to display the account
//--------------------------------------------
	public void print() {
	Account account = new Account();
	account.setId(1122);
	account.setBalance($20000.00);
	account.setWithdraw($2500);
	account.setWithdrawTotal($17500.00);
	account.setDeposit($3000.00);
	account.setDepositTotal($20500.00);
	account.setAnnualInterestRate(.045);
	
//------------------------------------------
// Displaying using the get methods
//------------------------------------------
	
	System.out.println("The Accound id is:" + account.getId());
	System.out.println("The Balance is:" + account.getBalance());
	System.out.println("Amount of withdrawal is:" + account.getWithdraw());
	System.out.println("The Balance after withdrawal is:" + account.getWithdrawTotal());
	System.out.println("Amount of deposit is:" + account.getDeposit());
	System.out.println("The Balance after depsoit is:" + account.getDepositTotal());
	System.out.println("The monthly interest for total amount is:" + account.getAnnualInterestRate());
	}
}

Account.java:94: ')' expected
account.setBalance($20000.0);
^
Account.java:94: illegal start of expression
account.setBalance($20000.0);
^

Well, for starters you could mark previous threads solved if you no longer have questions/are satisfied with the help you got. Some of these threads look like they are solved; if they are, then mark them as solved.

http://www.daniweb.com/forums/thread230080.html
http://www.daniweb.com/forums/thread229863.html
http://www.daniweb.com/forums/thread229842.html
http://www.daniweb.com/forums/thread229265.html

As for your question, it looks like you already almost have your withdraw method written. Since all a withdrawal does is changes your balance:

public double withdrawCalculuation() {
return balance - withdraw;
}

You could write a method called doWithdrawal that calls withdrawCalculation and sets the balance to whatever withdrawCalculation returns. Of course, your doWithdrawal method would assume that the 'withdraw' variable has already been set to the withdrawal amount (otherwise withdrawCalculation will not work properly). Also, you misspelled calculation in your method name.

thanks bestjew yeah i've closed out some of the threads that were solved... sorry for the inconvenience...... anyhow ok i see where i misspelled i'll try the doWithdraw

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.