*
The moose likes Swing / AWT / SWT and the fly likes last week of class last assignment. Any help is appreciated. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "last week of class last assignment. Any help is appreciated." Watch "last week of class last assignment. Any help is appreciated." New topic
Author

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

LeeAnne Murphy
Greenhorn

Joined: Aug 15, 2011
Posts: 18




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

Joined: Jul 26, 2007
Posts: 10175
    
    8

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.



[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
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

Joined: Aug 15, 2011
Posts: 18

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

Joined: Oct 24, 2010
Posts: 557
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?


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
LeeAnne Murphy
Greenhorn

Joined: Aug 15, 2011
Posts: 18

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

Joined: Aug 15, 2011
Posts: 18

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

Joined: Oct 24, 2010
Posts: 557
You should have code tags figured out by now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
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]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: last week of class last assignment. Any help is appreciated.
 
Similar Threads
I keep get a resolved to a variable error
I need to have my program take information from text file Plus my pie chart is in wrong place
Help with Java Mortgage Program
Help with errors again
GUI Mortgage Calculator