java - How to list multi-dimensional arrays values in a loop -


so first off, sorry if appears if asking homework...just me not, question involves 1 tiny little aspect of entire program in making...in other words isn't close finished.

i ask teacher, online course. ask friends advice, i'm kid in school taking computer science course. (it's small school)

anyways program when completed, allow teacher input list of students of 4 grades per student. i'll add code allows teacher find averages of each student etc etc.

however @ moment i'm in process of listing students. there small problem...

every time list student (their last , first name) along 4 test scores, outputs nicely. when go output second student different name , different test scores, outs different name...but test scores of previous student.

ex.

john smith: 67 68 57 87

jane doe: 67 68 57 87 (even though should jane doe: 54 68 75 91)

and problem...since students not have exact same grades...ever..

okay code below...

public class studentgradesview extends frameview {     int [][] arystudent = new int [15][4]; //[15] being number of students , [4] being test scores...     string[] studentnames = new string[15]; // i'm thinking might unnecessary now...but we'll see     int numofstudents = 0; //starting number of students @ 0....      int marks = 0;      int test1;     int test2;     int test3;     int test4;      public studentgradesview(singleframeapplication app) {         //unimportant...just stuff added gui..     }      private void addbuttonactionperformed(java.awt.event.actionevent evt) {         //test1field through test4field test scores....         arystudent[numofstudents][0] = integer.parseint(test1field.gettext());         arystudent[numofstudents][1] = integer.parseint(test2field.gettext());         arystudent[numofstudents][2] = integer.parseint(test3field.gettext());         arystudent[numofstudents][3] = integer.parseint(test4field.gettext());          stringbuilder sb = new stringbuilder();          (int x=0; x < numofstudents ; x++) {             sb.append(firstnamefield.gettext() + " " + lastnamefield.gettext());             (int y=0; y < 4; y++) {                 sb.append(" " +arystudent[x][y]);             }             sb.append("\n");         }         studentlistfield.settext(sb.tostring());         numofstudents ++;     }                                         } 

first of all, want

for (int x=0; x<= numofstudents; x++) 

or when numofstudents = 0 you'll never go loop.

also, addbuttonactionperformed have loop contains code you've given us? otherwise, seems every time go method numofstudents 0 , when exit it'll 1, code executed numofstudents = 0. missing something?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -