• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
how might I go about doing that?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Got it working Thank ya all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!