I'm fairly new with Java and I'm having some trouble understanding what I'm doing wrong. Here is a brief description of the purpose of the program.
- Make a bank account.
- Deposit 1000 into it.
- Withdraw 400.
- Withdraw 500.
- Print out results and expected results.
Here is my code. Keeps on saying non-static variable bankAcc
cannot be referenced from a static context.
public class BankAccountTester
{
private double bankAcc; //Stores bankAcc balance
public void money(double deposit)
{
deposit= (1000);
int withdraw1 = -400;
int withdraw2= -500;
bankAcc= bankAcc + withdraw1 + withdraw2;
}
public double getbankAcc()//Returns value to bankAcc so it has new balance
{
return bankAcc;
}
//Prints out value and expected value
public static void main(String[] args){
System.out.Println("My bank account has " + bankAcc);
System.out.Println("Expected is 100");
}
}