• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Creating a method to average grades out

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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!

 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the connection with Servlets?
 
author & internet detective
Posts: 39433
768
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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: 39433
768
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
please buy my thing and then I'll have more money:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!