<identifier> expected error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • camzgon121
    New Member
    • Mar 2008
    • 1

    <identifier> expected error

    Hi guys, I have this code and when I try to compile and run it gives me an <identifier> expected error.

    The code with the irrelevant parts taken out.

    Code:
    package ACCOUNT; 
    import java.util.Scanner; 
    import java.util.GregorianCalendar; 
    import javax.swing.*; 
    
    class Bank
    { 
    static private double bal; //Account balance 
    static int withdraw; //amount of times withdrawn 
    static void setBal(double amount){bal = amount;} 
    static double getBal(){return bal;} 
    
    public static void main(String[] args)
    { 
    //code 
    } 
    
    class Charge extends Bank
    { 
    double fee = Bank.withdraw * 0.10; 
    double tempbal = Bank.getBal(); 
    double amount = tempbal - fee ; 
    Bank.setBal(amount); 
    }
    when I run it points to the line Bank.setBal(amo unt) and says <identifier> expected

    can someone help?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by camzgon121
    Hi guys, I have this code and when I try to compile and run it gives me an <identifier> expected error.

    The code with the irrelevant parts taken out.

    Code:
    package ACCOUNT; 
    import java.util.Scanner; 
    import java.util.GregorianCalendar; 
    import javax.swing.*; 
    
    class Bank
    { 
    static private double bal; //Account balance 
    static int withdraw; //amount of times withdrawn 
    static void setBal(double amount){bal = amount;} 
    static double getBal(){return bal;} 
    
    public static void main(String[] args)
    { 
    //code 
    } 
    
    class Charge extends Bank
    { 
    double fee = Bank.withdraw * 0.10; 
    double tempbal = Bank.getBal(); 
    double amount = tempbal - fee ; 
    Bank.setBal(amount); 
    }
    when I run it points to the line Bank.setBal(amo unt) and says <identifier> expected

    can someone help?
    You need to go through a Java tutorial first before you start writing the Java code.
    Also make sure you design your program structure first (including class structure).

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Originally posted by r035198x
      You need to go through a Java tutorial first before you start writing the Java code.
      Also make sure you design your program structure first (including class structure).
      I agree. I was about to point out your specific mistake, but then I stepped back and looked at your entire code, and it was like seeing someone hammering nails with the handle of a screwdriver. You need to either go through some tutorials or find a good book.

      Sun's Java tutorials: http://java.sun.com/docs/books/tutorial/index.html
      A good intro book: Head First Java: http://www.oreilly.com/catalog/hfjava2/

      Comment

      Working...