wood burning stoves*
The moose likes Beginning Java and the fly likes new to java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "new to java" Watch "new to java" New topic
Author

new to java

Michael Cullen
Greenhorn

Joined: Sep 23, 2011
Posts: 10
I'm trying to make a program that will make a row of rings but it keeps telling me that this part of the main function is wrong. " rings(int n, double x, double y, double radius, double width);"

someone help me.






fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

Generally, it is of tremendous help if you post the actual error message, verbatim. What it says actually mean something.

my GUESS is that the problem is on line 19. When you call a method, you don't say what the variable types are. I think it should be this:



Note: I put code tags around your java to make it easier to read. next time, after you paste in your source code, just highlight it and click the 'code' button above, just like you would to make it bold or italic.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Michael Cullen
Greenhorn

Joined: Sep 23, 2011
Posts: 10
8 errors found:
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: '.class' expected
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: ';' expected
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: <identifier> expected
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: not a statement
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: ';' expected
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: <identifier> expected
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: not a statement
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 29]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:29: ';' expected

These were the error messages I received
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

ok...no offense, but you are in for a world of pain.

Never Never Never write 50 lines of code before you compile. I personally never write more than 2 or 3 before I compile. I fixed what I thought the problem was, recompiled...and now get TWENTY-TWO errors.

What the heck is StdIn, StdRandom, or StdDraw?

on line 19, you use variables x,y,z and radius, but you have never declared what they are.

Fixing this is going to be painful. I would seriously suggest you throw it out, start over, and recompile every time you write two new lines of code, fixing problems as you go.
Michael Cullen
Greenhorn

Joined: Sep 23, 2011
Posts: 10
I made the changes you suggested and received these errors.

Thanks again!



15 errors found:
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 19]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:19: cannot find symbol
symbol : variable x
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 19]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:19: cannot find symbol
symbol : variable y
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 19]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:19: cannot find symbol
symbol : variable radius
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 28]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:28: outlinedCircle(double,double,double,double,java.awt.Color) in Rings cannot be applied to (int,double)
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 45]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:45: filledCircle(double,double,double) in StdDraw cannot be applied to (<nulltype>,<nulltype>,double,double)
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 45]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:45: operator + cannot be applied to double,halfwidth
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 45]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:45: cannot find symbol
symbol : variable halfwidth
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 45]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:45: operator + cannot be applied to double,halfradius
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 45]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:45: cannot find symbol
symbol : variable halfradius
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 46]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:46: cannot find symbol
symbol : variable RANDOM
location: class java.awt.Color
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 47]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:47: filledCircle(double,double,double) in StdDraw cannot be applied to (<nulltype>,<nulltype>,double,double)
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 47]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:47: operator + cannot be applied to double,halfwidth
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 47]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:47: cannot find symbol
symbol : variable halfwidth
location: class Rings
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 47]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:47: operator + cannot be applied to double,halfradius
File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 47]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:47: cannot find symbol
symbol : variable halfradius
location: class Rings
Michael Cullen
Greenhorn

Joined: Sep 23, 2011
Posts: 10
the problem I have is that I don't know where to begin when writing a program like this so I used one that can make stripes and tried to adjust it for this.

thanks for the tip though
Michael Cullen
Greenhorn

Joined: Sep 23, 2011
Posts: 10
StdDraw opens up a window when I run it to draw the rings or squares or whatnot
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

Michael Cullen wrote:StdDraw opens up a window when I run it to draw the rings or squares or whatnot

So...it is another class you have already compiled and have on your machine? that makes it very hard for anyone here to help you.

But generally, when you get a list of 15 errors like this, you fix the first one first.

File: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java [line: 19]
Error: /Users/MichaelCullen/Desktop/Fall Semester/CS 101/Lib/Cullen1/Rings.java:19: cannot find symbol
symbol : variable x
location: class Rings

So, look on line 19. the compiler has no idea what 'x' is. looking through your code, have you defined a variable called 'x' anywhere, and set it to some value?

Looking at the definition of the 'rings' method, x should clearly be a double, so somewhere before line 19, you need something like:

double x = 2.0;

now, a better question is what the heck is x for? if you look at the definition of your rings method (lines 23- 30 in your original post), there is no variable x used. Sure, it is in the argument list, but it serves no purpose that I can see. I'd take it out of both the call and the definition/declaration of the method.

Doing either of the above (declaring x or taking it out of the call/method defintion) solves one error. Then you re-compile, and start fixing the next.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new to java
 
Similar Threads
Wanted: Java2D example of zooming and panning with scroll bars
Smiling Face
Rotating an ImageIcon
Hierachies and inheritance
Hierarchies, inheritance, polymorphism and interfaces