This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I'm supposed to complete computeStudentMean method and the displayMeans method. Method computeStudentMean accesses the four grades in each individual student record, computes the mean of the four grades and stores the result in mean. Method displayMeans list all the student name and their respective test averages.
For the computeStudentMean part, I know that I can convert an object into a primitive data type by doing somthing like this:
What I don't get is how to convert my Student object into like an integer, s I can add them up and find the mean. Also, for my displayStudentMean, I get the addresses instead of the actual numbers. Thanks in advance!
Originally posted by Conrad McLaughlin: Are you asking how to convert an object to an integer? To do so you have to convert the object to string first. Look at my example where the object is called fn, string is fn2 and integer is fn3.
I'm positive that this code, if you are able to compile it, will throw a runtime Exception. Integer.parseInt(String) can only parse a String that contains a parsable integer. The String returned by calling toString() on an array instance is definitely not a parsable integer. Rusty's idea was on the right track.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter