Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Help with Value Returning Methods

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
author
Posts: 23926
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 23926
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic