• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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've tried everything I can. What I have is.
a method that receives a string and returns it as int.
I get a name in main then do the math in here " public static int calculateCharacters(String text)" this is mandatory
then send it back as integer to main to print. I'm self teaching myself and I find quiz's to do.
And they want the calculation in seperate method
please help!

 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Barber wrote:please help!


I'm afraid ItDoesntWorkIsUseless (←click).

What's wrong with what you've written? Are you getting an error message? Does it return the wrong value?

Inquiring minds want to know...

However, just from a cursory glance: Where have you initialized the 'count' field that you reference in main()?

Winston
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Barber wrote:a method that receives a string and returns it as int.


Do you mean parsing a String? Like converting String "1234" to numerical value 1234?
Because you've got a method that returns a length of a string, so for a string "1234" it would return 4.
 
author
Posts: 23951
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

Pawel Pawlowicz wrote:

James Barber wrote:a method that receives a string and returns it as int.


Do you mean parsing a String? Like converting String "1234" to numerical value 1234?
Because you've got a method that returns a length of a string, so for a string "1234" it would return 4.




Also, the method is unused. There isn't any code that calls the method.

Henry
reply
    Bookmark Topic Watch Topic
  • New Topic