473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

<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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. package ACCOUNT; 
  3. import java.util.Scanner; 
  4. import java.util.GregorianCalendar; 
  5. import javax.swing.*; 
  6.  
  7. class Bank
  8. static private double bal; //Account balance 
  9. static int withdraw; //amount of times withdrawn 
  10. static void setBal(double amount){bal = amount;} 
  11. static double getBal(){return bal;} 
  12.  
  13. public static void main(String[] args)
  14. //code 
  15.  
  16. class Charge extends Bank
  17. double fee = Bank.withdraw * 0.10; 
  18. double tempbal = Bank.getBal(); 
  19. double amount = tempbal - fee ; 
  20. Bank.setBal(amount); 
  21. }
  22.  
  23.  
when I run it points to the line Bank.setBal(amount) and says <identifier> expected

can someone help?
Mar 10 '08 #1
2 4420
r035198x
13,262 8TB
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. package ACCOUNT; 
  3. import java.util.Scanner; 
  4. import java.util.GregorianCalendar; 
  5. import javax.swing.*; 
  6.  
  7. class Bank
  8. static private double bal; //Account balance 
  9. static int withdraw; //amount of times withdrawn 
  10. static void setBal(double amount){bal = amount;} 
  11. static double getBal(){return bal;} 
  12.  
  13. public static void main(String[] args)
  14. //code 
  15.  
  16. class Charge extends Bank
  17. double fee = Bank.withdraw * 0.10; 
  18. double tempbal = Bank.getBal(); 
  19. double amount = tempbal - fee ; 
  20. Bank.setBal(amount); 
  21. }
  22.  
  23.  
when I run it points to the line Bank.setBal(amount) 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).
Mar 10 '08 #2
BigDaddyLH
1,216 Expert 1GB
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/
Mar 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Torsten Reiners | last post by:
Hi, it might be a simple solution but I do not see it. The problem is that I have the following file stored on my local harddrive. All references are URL to a remote computer. It is working,...
5
by: Vinu | last post by:
Hi I am facing a problem in compilation the error is like this In constructor xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>,...
19
by: benzwt | last post by:
I use the following function to hide a <div> named one. function hideObject() { if (ns4) { document.n1.visibility = "hide"; } else if (ie4) { document.all.style.visibility = "hidden"; }...
14
by: Stefan Mueller | last post by:
With the following code I can add a new row to an existing table. That really works great. Many thanks to all who helped me so far. But my problem is that the added cells do somehow not have the...
6
by: Bobrick | last post by:
Hi. Thanks to everyone who replied to my last post, it turns out it wasn't the line where I was trying to treat the variable in question as an array which was the problem, but the line above. ...
49
$
by: google | last post by:
what dose a $ do in javascript, i have been given a bit of code and there are $'s all over the place, can someone explain their uses
4
by: CodeTilYaDrop | last post by:
I am still pretty new to programming, and I sometimes can not figure something out. I am getting an error with this line in my program: Public void count_syllables(int count_syllables) I get...
1
by: Prat4u | last post by:
Hi I'm having <identifier> expected error when i compile the following code in the test application in java. Player player = new Player("Red Guy", Color.red, new Point(100,100), 0); ...
3
oll3i
by: oll3i | last post by:
package ejb; import javax.ejb.EJBObject; import java.rmi.RemoteException; import java.sql.Connection; import java.util.Map; public interface InterfaceRemote extends EJBObject { public Map...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.