Results 1 to 2 of 2
  1. #1
    xcaldk74 is offline Member
    Join Date
    Jan 2012
    Posts
    40
    Rep Power
    0

    Default 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:
    Java 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

    Java 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

  2. #2
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    349
    Rep Power
    4

    Default Re: Simple Bank Account Class CRASHES help!

    1122 is not a valid variable name.

    Regards.

Similar Threads

  1. Simple Bank Account Program - Completely Confused
    By Interista in forum New To Java
    Replies: 4
    Last Post: 11-02-2011, 02:12 AM
  2. basic bank account
    By captain_turkiye in forum New To Java
    Replies: 5
    Last Post: 10-16-2011, 05:15 PM
  3. Bank Account Project
    By Haal in forum New To Java
    Replies: 0
    Last Post: 03-20-2011, 07:30 PM
  4. Create a java class for a bank account!!?
    By singh345 in forum New To Java
    Replies: 1
    Last Post: 03-17-2010, 04:26 PM
  5. Bank Account
    By HPcompaq256 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 09:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •