Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

last week of class last assignment. Any help is appreciated.

 
LeeAnne Murphy
Greenhorn
Posts: 18
Firefox Browser Netbeans IDE Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



the errors are on line 22, 34, 181, and 187 - I don't understand the errors - need explanation in simple terms...Sorry keep forgetting things

line 22 error - class wk5calcjp2 is public, should be declared in a file named wk5calcjp2.java
line 34 error - illegal start of expression
line 181 error - bad operand types for binary operation, first type; int [] second type; int
line 187 error - inconvertible types required: int, found :<any> and also bad operand types for binary operation, first type; [] second type; int
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
line 22 error - class wk5calcjp2 is public, should be declared in a file named wk5calcjp2.java

Thats self explanatory. What is the name of your java file? It should be wk5calcjp2.java. Note: In Java case does matter

Other errors:
Reformat/restructure your code properly to follow this pattern

package statement
import statement(s)

class declaration{

field variable declaration(s)
constructor(s)
method(s)
}

Pay special attention to the scope, i.e. where your curly braces start and end.


 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you write all this code? You should never never NEVER NEVER get to the point where you have 500 lines of code before you compile. You're making it too hard on yourself.

Write 2-3 lines AT MOST before you compile. Then test it, and then test it some more. Only after you are sure of those few lines should you think about writing your next few lines.

You should have found this error the very first time you compiled. and you should have not written another line until it was fixed.

as Maneesh said, the first error should be self-explanatory. Since your class is public, the filename MUST match the class name, and it IS case sensitive, even if your OS (i.e. windows) is not.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your illegal starts of expression are because you have no } at the end of your main method. You are probably writing from the top line to the bottom line, which I don't think is right. Look at this old post.
Your indentation is inconsistent, which makes it harder to see where your classes and methods start and finish. And use spaces, not tabs, for indenting. Also put single spaces before and after each binary operator.
You are doing better than many with your Listener class: at least there is no "addXYZListener(this)" anywhere. But it is still not object-oriented. You should have a Listener for each action required. I don't think you should have so much in the actionPerformed() method. I would suggest something like thisI'll let you work out how to locate that class so everything's in the appropriate scope. Also how to write the calculateInterest() method. You have probably already got it all written somewhere and simply need to move the code into its own method.

I think at this stage your discussion would fit better into our GUIs forum, so I shall move it.
 
LeeAnne Murphy
Greenhorn
Posts: 18
Firefox Browser Netbeans IDE Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I figured out what I did wrong..wasn't paying attention to spelling. I know this is a lot of code but for the class this is the only way I kinda understand...so I am still not getting this stuff. I am dumb when it comes to this type of programming so I try to remember what I have done from week to week and use the book as guideline but still not fully understanding.

Here is the portion from the original code that is still giving me problems. I just don't understand what is being explained to me...as I said I am dumb when it comes to java programming



bold is what is giving the errors
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not dumb. Just as you weren't paying attention to spelling, you don't seem to be as attentive to all of the programming details as you need to be. Don't give up. Will you take another programming class?

As for your errors:

The error is telling you that you're trying to do something with one (or more) of your operators that is not allowed. In this case, what is the variable dblLoanDuration? If you were to try and solve those equations, what value would you substitute for that variable name?

 
LeeAnne Murphy
Greenhorn
Posts: 18
Firefox Browser Netbeans IDE Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't need to take another java programming class. This one ends on Monday and then I have a week off and start Introduction to Unix. I just can't get the hang of programming in java, I have struggled for the last 4 weeks in class.
 
LeeAnne Murphy
Greenhorn
Posts: 18
Firefox Browser Netbeans IDE Windows Vista
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I completely re-wrote my code. Now if I click on the chart option for my gui it gives these errors.


Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented
at jp2wk5calc.Chart.<init>(Chart.java:14)
at jp2wk5calc.JP2wk5calc.onButtonChart(JP2wk5calc.java:318)
at jp2wk5calc.JP2wk5calc$4.actionPerformed(JP2wk5calc.java:144)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6288)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:616)
at java.awt.EventQueue$2.run(EventQueue.java:614)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Here is my code


 
Greg Brannon
Bartender
Posts: 563
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have code tags figured out by now.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the tags are a bit confusing. You have to put the code after the first ] and before the second [

The Exception means you have either let NetBeans write the code for you, or found an example of mine where I used UnsupportedOperationException. It is a correct approach to an empty method, to put such an Exception into it. That means you get a warning when you call a method you haven't actually written. To sort that out, you need to find the offending method, write the method, and get rid of the line starting throw new. You should be able to find it from the stack trace. It means it is in line 14 of the Graph Chart class. It also tells you which method: for <init> read "constructor".

[edit]Corrected graph to chart[/edit]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic