• 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

problems with return method involving arrays

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The output is :

The numbers in the array are: 1 2 3 4 6 7 8 9 10 13 14 15
The highest grade is: 11




I have no idea what is wrong with the code. Please Help
For some reason it is not giving me the highest number in my array. Did I write the method wrong ? Is my array even passing through HighestGrade ?
 
Saloon Keeper
Posts: 10732
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what you intended on doing but you are printing the index into the array and not the value at that index.
 
Mulk Abdulhadi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:Not sure what you intended on doing but you are printing the index into the array and not the value at that index.




I am just trying to print out the highest grade which would be 15 .
 
Carey Brown
Saloon Keeper
Posts: 10732
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mulk Abdulhadi wrote:

Carey Brown wrote:Not sure what you intended on doing but you are printing the index into the array and not the value at that index.




I am just trying to print out the highest grade which would be 15 .


Yes, and you're printing out the index into the array at which '15' resides.
 
Mulk Abdulhadi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So , how do I make it print out 15 ?
 
Carey Brown
Saloon Keeper
Posts: 10732
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In this method you already have an example of how to get a grade from the max index (hint: line 6).
 
Mulk Abdulhadi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WOW , okay I got it . Thanks for your help .

I just changed:

 
I am going to test your electrical conductivity with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic