Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Organizing Arrays in Programming?

Okay. I have a problem (yes, for a class. no, not looking for the answer - just bouncing what I think) in which I have to write the pseudocode for a program that accumulates grades for each of 30 different classes. Each class can have up to 35 students and each student has a grade on a test from 0-100. What I have in my Declarations is as follows:

num stuID(35)

num CLASS[30] = 1, 2, 3, 4, 5, 6, 7, 8, 9, (etc to thirty)

num SCORE[100] = 1, 2...100

those are the significant declarations, anyway. Would this be right? I then have to prompt for # of students, grade and accumulate the grades...

3 Answers

Relevance
  • 6 years ago

    About the "num stuID(35)" declaration:

    The assignment doesn't say 35 students total...just that there are at most 35 per class. Aren't there more students at your school than are in your largest class?

    With 30 classes and up to 35 students, something has to have room for at least 30*35 = 1,150 entries. Normally, that would be described as a two-dimensional array with 30 rows (one for each class) and 35 columns (one for each seat in the class).

    Notice I said "seat", not "student". The first position in each row will be occupied by a different student in each class, typically, so for each position you need two pieces of information: A student ID or name saying who's in that seat, and a score on the test for that student.

    You can use an array of struct or record types to keep two pieces of information together in one array location, or you can use parallel arrays. Use whichever you've studied, but be aware that both approaches exist in most programming languages. (Classic FORTRAN had no record types, so parallel arrays were almost mandatory there.)

    Reading again, there's nothing in what you've typed about either a student ID or name, so you'll have to look at what displays or reports you're required to produce to see what information you must collect at data entry time.

  • AJ
    Lv 7
    6 years ago

    Ok but what programming language?

    Because the best way to handle this is to create a class that represents a single student in a single course class and put that class into a List<t> or an arraylist, depending on the programming language.

  • 6 years ago

    It isn't in a programming language. It's pseudocode. The book isn't even geared toward any of the main languages. It brings up each one constantly which is only more confusing. The examples in it are terrible and it doesn't explain half of what you're supposed to do.

Still have questions? Get your answers by asking now.