So, let's assume that the array of grades is completely filled. No partially
filled arrays on this question. Can you write a method which returns the sum of
the scores for the ith student? If you're ready to try this for yourself, just
skip to the quiz. If you want to see a smaller example first, keep watching.
What if my grade book looked like this, and I wanted to calculate the total for
Sandra. Sandra is at index i equals one. If this whole array was called grades,
then I would want to add up this cell, which would be grades [1] [0], because
this is the first student. And the zeroth topic would be this spot, because
it's student one and topic one. And grades [1] [2] would be this one, Student
One, Topic Two. To get the sum for this student we would want to add all of
these up. Now, it's your turn. Try coding this in BlueJ. But bare in mind, you
might not know the size of the array up front. There might be a variable for
the number of topics and the number of students.
Así que asumamos que el «array» de calificaciones está completamente lleno. No hay «arrays» parcialmente llenos
en esta pregunta. ¿Pueden escribir un método que devuelva la suma de
las calificaciones del estudiante «i»? Si están listos para intentar esto solos,
salten hasta la prueba. Si quieren ver primero un ejemplo más pequeño, sigan observando.
¿Y si mi libro de calificaciones se viera así y yo quisiera calcular el total de
Sandra? Sandra está en el índice i que es igual a uno. Si todo este «array» se llamara calificaciones,
entonces, tal vez quisiera sumar esta celda, que sería calificaciones [1] [0], debido a que
éste es el primer estudiante. Y el tema cero sería este espacio, porque
es el estudiante uno y el tema uno. Y las calificaciones [1] [2] sería éste, Estudiante
Uno, Tema Dos. Para obtener la suma para este estudiante, nos gustaría sumar
todos estos. Ahora es su turno. Intenten codificar eso en BlueJ. Pero tengan en mente,
podrían no saber el tamaño del «array» por adelantado. Puede haber una variable para
el número de temas y el número de estudiantes.
Donc, supposons que le tableau des
notes est complètement rempli,
pas de tableaux partiellement
remplis sur cette question.
Pouvez-vous écrire
une méthode qui renvoie
la somme des scores pour le ième étudiant?
Si vous êtes prêt à essayer par vous-même,
passez simplement au quiz.
Si vous voulez voir un exemple plus
petit d'abord, continuez à regarder.
Et si mon carnet de notes
ressemblait à ceci
et je voulais calculer
le total pour Sandra?
Sandra est à l'indice i = 1.
Si tout ce tableau était appelé grades,
alors je voudrais ajouter cette cellule,
qui serait grades [1] [0],
parce que c'est le premier étudiant.
Et le sujet 0 serait cet endroit,
car c'est étudiant 1 et sujet 1.
Et grades [1] [2] serait celle-ci,
étudiant 1, sujet 2.
Pour obtenir la somme pour cet étudiant,
nous voudrions ajouter tout cela.
C'est à votre tour.
Essayez de coder ceci dans BlueJ.
Mais gardez à l'esprit,
vous pourriez ne pas connaître
la taille de la matrice à l'avant.
Il pourrait y avoir
une variable pour
le nombre de sujets et
le nombre d'étudiants.
では成績の配列が
完全に埋まっているとしましょう
これは部分的に使用された配列ではありません
i番目の生徒のスコアの
合計を返すメソッドを書けますか?
小テストへ移動するか
または例題が必要なら続きを見てください
このような成績表からサンドラの合計を計算します
彼女はインデックスiなのでi=1です
全体の配列名をgradesとし
このセルを足すとすると
grades[1][0]になります
なぜなら1番目の生徒の
ゼロ番目のトピックだからです
ここは生徒1のトピック1で
grades[1][1]です
ここは[1][2]です
これらすべてを足してこの生徒の合計を出します
では皆さんがBlueJでコード化してみてください
配列のサイズは分からなくても
トピック数と生徒数の変数はあります
이 문제에서는 부분적으로 채워진 배열은 없는 걸로 하겠습니다.
i번째 학생의 점수를 모두 합친 결과를 리턴 하는 메소드를 구현할
수 있을까요? 이를 여러분 혼자서 할 수 있다면 퀴즈로 바로 넘어가시면
됩니다. 이해가 더 필요하다면 계속 보시면 됩니다.
성적이 모두 이렇게 생겼다면, Sandra의 총점을 구하고
싶습니다. Sandra의 인덱스는 i=1에 있습니다. 이 배열의 이름이 grades였다면,
이 부분은 grades[1][0]입니다. 왜냐하면 이 부분이
인덱스 1의 학생이고, 0번째 주제는 여기이기 때문입니다. 여기는
grades[1][1]이고 여기는 grades[1][2]가 됩니다. 학생 1의
주제 2입니다. 우리는 이렇게 학생의 총점을 얻고 싶습니다.
이제 여러분이 할 차례입니다. Bluej에서 해보길 바랍니다.
배열의 크기를 꼭 알고 있길 바랍니다. 아마 주제의 수와
학생의 수를 저장하고 있는 변수가 있을 겁니다.