Results 1 to 3 of 3
  1. #1
    Niehm is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default No main methods ?

    Hello everyone.

    Here is my problem, I wrote this this morning for my beginner Java class (pun unintended :P) but for some obscure reason eclipse won't compile it claiming that there aren't any main method anyone can help me out on that please ?

    Java Code:
    import java.util.Date;
    
    public class Account {
    	
    public void main(String[] args) {
    		
    		Account account = new Account (1122, 20000 );
    		
    		
    		setannualInterestRate (4.5);
    		
    		withdraw (balance, 2500 );
    		
    		deposit (balance, 3000);
    		
    		System.out.println ("The balance of the account " + id + " is " + getbalance() + " with a monthly rate of " + getMonthlyInterestRate(annualInterestRate) + " starting " + getDate () + ".");
    	}
    
    
    
    private int id = 0;
    private double balance = 0;
    private double annualInterestRate = 0;
    private Date dateCreated = new Date ();
    
    
    public Account (){
    	
    }
    
    public Account (int id, double balance){
    	
    }
    
    public Date getDate(){
    	
    	return dateCreated;
    	
    }
    
    public double getbalance (){
    	
    	return balance ;
    }
    
    public void setbalance (double balance){
    	
    	this.balance = balance;
    }
    
    public double getannualInterestRate (){
    	
    	return annualInterestRate;
    }
    
    public void setannualInterestRate (double annualInterestRate){
    	
    	this.annualInterestRate = annualInterestRate;
    }
    
    public int getid (){
    	
    	return id;
    }
    
    public void setid (int id){
    	
    	this.id = id;
    	
    }
    
    public double getMonthlyInterestRate (double annualInterestRate){
    	
    	double monthlyInterestRate = annualInterestRate/12;
    	
    	return monthlyInterestRate;
    }
    
    public double withdraw (double balance, double withdrawn){
    	
    	balance -= withdrawn;
    	return balance;
    	
    }
    
    public  double deposit (double balance, double deposited){
    	
    	balance += deposited;
    	return balance;
    	
    }
    
    }

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default Re: No main methods ?

    void main needs a static modifier

  3. #3
    Niehm is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

Similar Threads

  1. how can main call other methods?
    By rahuld.exe in forum New To Java
    Replies: 1
    Last Post: 04-06-2012, 02:19 PM
  2. Replies: 9
    Last Post: 11-18-2011, 11:47 PM
  3. compile error - calling methods from main
    By counterfox in forum New To Java
    Replies: 1
    Last Post: 04-16-2010, 06:00 PM
  4. Classes and main methods?
    By CyberFrog in forum New To Java
    Replies: 17
    Last Post: 05-26-2009, 05:47 AM
  5. [SOLVED] Mulitple main methods
    By MuslimCoder in forum New To Java
    Replies: 6
    Last Post: 02-10-2009, 02:49 AM

Posting Permissions

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