• 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

Creating a method to average grades out

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

I am creating a program to average grades from an array. As you can see, I can load the array properly but now I need to send the info to a method and then have it dispense the name of the student (stored in one array) and the average grade of each student (taken from the data from another array). Any help would be amazing!

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the connection with Servlets?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch! I added [ code ] tags to your post to make it easier to read. I'm going to move this thread to our beginning java forum where it fits better.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know how to create a method that just prints "hello world"? How about printing out the name of each student?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Couldn't line 19. be:



Then in the for loop that starts at line 35. You could initialize an integer or double primitive (depending on whether to display decimal places) so line 36 could be replaced with:



So for each student the grade average variable would be reset then as you get iterate through the inner loop you total up the grades then you could have at the end of the inner loop (after the enclosing curly brace) which totals the grades the following:



The above is a hard-coded length but I'm sure you can get this length from one of the arrays. Depending on the displaying decimal places you could use a primitive double or integer. And then use a formater to determine the maximum number of decimals to display if you are displaying decimal places.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic