aspose file tools*
The moose likes Beginning Java and the fly likes Help with Value Returning Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Value Returning Methods" Watch "Help with Value Returning Methods" New topic
Author

Help with Value Returning Methods

Mike Devenport
Greenhorn

Joined: Feb 26, 2011
Posts: 3
I'm working on a program that will calculate various mathematical problems pertaining to different shapes using formulas & user input. The problem that I am having is: writing the static method named "circleArea" that will take in the radius of the circle and return the area using the formula A=PI*Rsquared (3.14*(radius*radius)). I've added the lines in the main method to call the method but it still isn't calculating correctly. Where am I messing up at? Thanks for your support.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18117
    
  39


With the exception of the two extraneous lines (line 54 and 55) which I removed, everything compile and ran fine. The calculation looks correct to me.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
It really helps if, instead of saying something like "it still isn't calculating correctly. Where am I messing up" you tell us what it is doing that you don't expect, exactly. Since exactness can be difficult, some suggest copying and pasting things from consoles, or screen shots of screens, whatever. But just "it don't work" doesn't tell us what problem you're having.

rc
Mike Devenport
Greenhorn

Joined: Feb 26, 2011
Posts: 3
Ralph Cook wrote:It really helps if, instead of saying something like "it still isn't calculating correctly. Where am I messing up" you tell us what it is doing that you don't expect, exactly. Since exactness can be difficult, some suggest copying and pasting things from consoles, or screen shots of screens, whatever. But just "it don't work" doesn't tell us what problem you're having.

rc


Ok thanks, for future reference, I will be more detailed in the problem.
Mike Devenport
Greenhorn

Joined: Feb 26, 2011
Posts: 3
Henry Wong wrote:
With the exception of the two extraneous lines (line 54 and 55) which I removed, everything compile and ran fine. The calculation looks correct to me.

Henry


Ah yes, when I removed line 54 and 55 it worked. Thanks for pointing that out, I guess when you establish the method outside of the the switch it uses that formula correct?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18117
    
  39

Mike Devenport wrote:
Ah yes, when I removed line 54 and 55 it worked. Thanks for pointing that out, I guess when you establish the method outside of the the switch it uses that formula correct?


Not sure what you mean. Line 54 is a compile error because you are trying to declare a variable that name clashed with another variable declared earlier. Line 55 is a compile error because you tried to use a variable that doesn't exist. Regardless, neither line were necessary, so I removed them.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Value Returning Methods
 
Similar Threads
its a classic! help with area of shapes!
problems
Programing challenge
Circle program errors
Calling methods using dynamic binding