Simple Bank Account Class CRASHES help!
Hi,
I've created class Account with all setters and getters and mainProgram. When I'm trying create new account program crashes and I have no clue where my issue is. Any advice? Thank you in advance.
class code:
Code:
//data members
class Account
{
private int id;
private double balance;
private double annualInterestRate;
private double dateCreated;
//constructor
public Account(int id, double balance, double annualInterestRate)
{
//this.id = id;
//this.balance = balance;
//this.annualInterestRate = annualInterestRate;
id = 0;
balance = 0;
annualInterestRate = 4.5;
}
//setter
public void setId(int id)
{
this.id = id;
}
public void setBalance(double balance)
{
this.balance = balance;
}
public void setAnnualInterestRate(double annualInterestRate)
{
this.annualInterestRate = annualInterestRate;
}
//getter
public int getId()
{
return(id);
}
public double getBalance()
{
return(balance);
}
public double getAnnualInterestRate()
{
return(annualInterestRate);
}
}
mainProgram
Code:
import java.util.Scanner;
public class mainProgram
{
public static void main(String [] args)
{
//id = 1122;
Account 1122 = new Account(1122, 20000.0, 4.5);
}
}
Errors I'm getting:
mainProgram.java:9: error: not a statement
Account 1122 = new Account(20000.0, 4.5);
^
mainProgram.java:9: error: ';' expected
Account 1122 = new Account(20000.0, 4.5);
^
2 errors
Re: Simple Bank Account Class CRASHES help!
1122 is not a valid variable name.
Regards.