• 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

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: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • 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: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • 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: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • 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
 
I was her plaything! And so was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic