This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Back to rational problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Back to rational problem" Watch "Back to rational problem" New topic
Author

Back to rational problem

Stacey Johnson
Ranch Hand

Joined: Jan 11, 2004
Posts: 55
Hi all!
Well I had to take a break for a bit but now I'm back and working on my rationals problem. I'm suppose to have an output like the following:
1/1 + 1/2 + 1/3 + ...+ 1/n
1/1 + 1/2 + 1/2^2 +...+ 1/2^n
I think I've got my constructor mostly cleaned up but I'm still getting a few errors that I"m not sure what to do. Below is my code then the errors:

Some of my errors are:

cannot resolve symbol
symbol : constructor Rtnl (int,int)
location: class Rtnl
Rtnl sum = new Rtnl(0,1);
^
java:61: cannot resolve symbol
symbol : constructor Rtnl (int,int)
location: class Rtnl
Rtnl x1 = new Rtnl(1,x);
^
java:62: cannot resolve symbol
symbol : method add (Rtnl)
location: class Rtnl
sum = sum.add(x1);
^

I'm sure you can see a theme of my errors, but I just don't know what to do. Can anyone help?
Stacey
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Your constructor needs round braces '( )'.

similiar it is with the methods:

but since you don't call them, you may delete them.
Reread about the syntax of methods.
about initialising variables.
I would go a few steps back in the Excercises, since you missed a lot of points. (When solving your errors, new ones which where hidden occur - and I can't even see what you're trying to do...


http://home.arcor.de/hirnstrom/bewerbung
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
You have multiple problems here, and you confused the compiler. The good news is, all of your problem are of the same nature, such as in this segment of your code:

This is not how a method is defined in Java. Perhaps what you meant was the code below?
Stacey Johnson
Ranch Hand

Joined: Jan 11, 2004
Posts: 55
Hello,
Okay I've fixed the stupid error regarding the () but what does the following error mean?
java:62: cannot resolve symbol
symbol : method add (Rtnl)
location: class Rtnl
sum = sum.add(x1);
^

Stacey
C. Nimo
Ranch Hand

Joined: Mar 23, 2004
Posts: 82
sum is an Rtn1 object.
you are trying to invoke a method called add() on this object.
however, your Rtn1 class has no method definition for add()
Stacey Johnson
Ranch Hand

Joined: Jan 11, 2004
Posts: 55
I'm completely lost. I don't know what to do anymore. Do I need constructors in this code to get my end result or have I been led down the wrong path. I am sooo close to quitting my course because I just don't know what to do with this program anymore. I don't even know where to look to find answers to my questions and errors. Is there anyone out there to shed some light on this for me? I feel like I'm beating my head against the wall.
 
GeeCON Prague 2014
 
subject: Back to rational problem