• 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

won't print information from inside methods....

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote this program so that a user could enter a list of student names, and grades. There are seperate methods that calculate and print an average grade, print the students' names whose grades are below the average, and print the highest grade as well as the students who have achieved it. My problem is that when I run the program, it doesn't print anything from the inner methods, it prompts for the grades and names and then exits. Any help in getting this to run correctly would be greatly appreciated. Thank ya!

[ December 03, 2003: Message edited by: Brandi Love ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to my eyes, main() prompts for the names and grades, and then exits, so your observation is not surprising. It never calls any of the other methods. If you want those other methods to execute, then main() has to invoke them!
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how might I go about doing that?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This won't fix the problem of the inner methods not printing, but I would suggest you use an ArrayList instead of arrays for the names and grades. This would make the program slightly more user friendly, since they would not have to count how many grades they are going to be entering.
Angel
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same way you're calling other methods in main(), except that since they're static methods in the same class, you can call them "bare" without calling them in the context of an object or class. So, for example, to display the grade average after collecting the grades, you'd write
GetAverage(gradeArray, numGrades);
at the end of main(); similarly for the other methods. Note that the name of this method is rather misleading, by the way -- it doesn't get anything, it prints something.
 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it working Thank ya all.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic