Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Student Markbook

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a project for a computer programming course, and this is the project I was given :

You must use arrays, for loops and methods to complete the project.
You are to write a program that will do the following:

-  Asks the user how many records they would like to enter.
- Prompt the user for the name of the student.
- Prompt the user for the student's mark in....Math, English, Social Studies and Science.
- Continue till all the records have been inputted.
- Displays a table with the each student and their marks.
- Gives the class average in each subject.
- Gives the minimum and maximum mark in each subject.
- Gives the student’s overall average.
- Gives the Classes’ overall average.

Hints:


   }

The issue i'm having is that this is new for me, so I have not used all of this data before. I am having trouble assigning the marks of the studnets. This is the code I used to put the students names into an array :



I am unsure of how to assign the values for each students mark to the students name. Just looking for the right idea, because once I know how to assign it for one student it is obviously pretty simple to repeat the process for the rest. Thanks!
     
 
Saloon Keeper
Posts: 8609
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd need an additional 2D array: new int[student][class].
Note that in reality Java does not have 2D arrays, it has arrays of arrays. But if all second level arrays are of the exact same length, it behaves like a 2D array.
 
J Hiddleston
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:You'd need an additional 2D array: new int[student][class].
Note that in reality Java does not have 2D arrays, it has arrays of arrays. But if all second level arrays are of the exact same length, it behaves like a 2D array.



Would you mind giving an example of how to do that? I'm not quite sure what you mean by new int[student][class]


Thanks!
 
Carey Brown
Saloon Keeper
Posts: 8609
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You already have
You'll need a similar line to allocate a 2D array for the grades.
Your requirements tell you what the number of classes is.
 
Carey Brown
Saloon Keeper
Posts: 8609
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that while the Java compiler accepts this syntax for historical reasons
Java conventions say you should write it this way
 
reply
    Bookmark Topic Watch Topic
  • New Topic