• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error - not a statement

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quick question....I keep getting error saying not a statement to the following code section. The below is not my whole code, but that is the part I am getting an error on...at least for now. Can anyone tell me what I have wrong...is it the () or something inside. I am probably just missing it.

 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Holly,



Joyce
[ October 20, 2004: Message edited by: Joyce Lee ]
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Count your parentheses as you scan from left to right. Start with 0 and for each ( add 1 and for each ) subtract 1. When you get to the end of the statement, if you aren't at 0, you have a problem.Check the other lines though, too.
[ October 20, 2004: Message edited by: David Harkness ]
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great Thank you for that help!! Kinda dumb huh?? LOL. Oh well. Now on to the hard stuff for me. I am in the process of learning about methods and so on, so what kinda of tips can you give me for the following code. And trust me I know I have tons of erros, I just dont have anyone to help me out. The people in my class wont study or anything so I come here to look for some guidance. So thank you in advance for any help you may can give. Thanks!


 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think one of the main problems is the the variables i declare in the beginning of public static void main( String[] args ). Is that right? I think that may be why I am getting the errors, what do yall think?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You have to specify a type when you declare a variable, so, for example, you have to say "int customercount = 0;".

Later on, I see you using "usage" without having declared it anywhere, either. Every variable's type has to be specified either before you use it altogether, or when it is first assigned to.
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok great thanks...I will get to work on that. I really appreciate the help!!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"so what kinda of tips can you give me for the following code."

Break everything down to individual tasks, then work on one at a time
eg
write a program to get customer numbers (with an exit routine)
compile/run - you will discover an error at "showInputDiaolg("
fix/compile/run

when this is working, include getting kwh
complie/run/fix/compile/run etc

add findCharge()
test, when OK
add increments to cumulatives
test
add output method
test
when OK
feet up, take a break.
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok great I got it to compile so now I need to work on the JTextArea cause obviously that is not right...huh? At least I am getting there.
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Holly,

If I were you, I'd pay close attention to what Michael is saying.
Try to work out a code-compile-test-debug cycle.
Write the minimum amount of code that you need to (maybe as little as 3 or 4 lines), compile it, run it, fix any errors before you go back to writing more code.
This is something that will help you now, when learning how to program, and later when you are doing real life coding.

cheers
Sonny
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I will for sure do that for now on, I see how much easier that is than throwing something together and going now what. So I apprecaite that and I will do that for now on, that way I will know what the problem is and be able to go right to the problem. Thanks!!
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more recommendation: use constants with meaningful names instead of "magic numbers" in your code. What does 300 mean, or 0.9, or 0.8?

Consider something like:


Obviously you could eliminate a bunch more magic numbers and magic expressions, and I was guessing at the meaning of the ones I did eliminate. There's still a lot more you could do to simplify the logic here. The goal is to make your code so that someone else can read and understand what it does and what it means. Also, simplifying things in this manner will often help point out mistakes that might otherwise be difficult to find.

-J-
[ October 21, 2004: Message edited by: Jeff Langr ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic