# Need some help with logic (hw question)

Page 1 of 1

## 5 Replies - 6756 Views - Last Post: 28 August 2009 - 08:11 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=67540&amp;s=b5f00bf21ee864f62a900fa67c21a165&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 xalu

Reputation: 0
• Posts: 10
• Joined: 14-October 08

# Need some help with logic (hw question)

Posted 14 October 2008 - 08:52 AM

First off I want to say thank you so much for any help. This is my first class geared toward computer science and so far I have gotten it through and through. My professor is somewhat unavailble and I have been emailing him a lot so I figure I would look for some help.

I am trying to write in pseudocode. The chapter this assignment is in is titled arrays. I just can't figure out the array process. I understand what I need to do. I just can't seem to get it into a code.

Heres the assignment.

Quote

Watson Elementary School contains 30 classrooms numbered 1 through 30. Each classroom can contain any number of students up to 35. Each student takes an achievement test at the end of the school year and receives a score from 0 to 100. Write a program that accepts data for each student in the school - Student ID, classroom number, and score on the achievement test. Design a program that lists each classroom's average of the test scores.

This is as far as I can get.

```start
num studentId
num score
num numStudents
sting classSize=35
string class=1
string numClass=30
string average
get studentId, score, numStudens

```

I understand that I need to
1. get studens id for class 1, get number of students in that class.
2. get test scores for class 1
3. add all test scores then divide by number of students in the class...
4. print the average of the class.
5. repeat until class 30 is printed.

I just cant figure out the logic/pseudocode.

I really appreciate any help.

If this is the wrong place to post I am sorry...please let me know the correct place.

Is This A Good Question/Topic? 0

## Replies To: Need some help with logic (hw question)

### #2 jjsaw5

• I must break you

Reputation: 90
• Posts: 3,060
• Joined: 04-January 08

## Re: Need some help with logic (hw question)

Posted 14 October 2008 - 11:37 AM

I'm going to move it into the "Other Languages" Section.

### #3 baavgai

• Dreaming Coder

Reputation: 6294
• Posts: 13,460
• Joined: 16-October 07

## Re: Need some help with logic (hw question)

Posted 14 October 2008 - 01:05 PM

Create a structure or class to hold the information you need. ( Not knowing what language you intend to use, it's hard to be specific. )

```typedef struct {
int studentId;
int classroom;
double  score;
} TestData;

```

Create an array of that type, or vector, or ArrayList. Collect the data. Then just write some functions to derive the information you need. You could write a loop that adds up all the scores for classroom X. Another that counts the current number of students, to validate the input data, etc.

There are more complex and possibly efficient ways to do this, but this approach would meet your requirements with minimal fuss.

Hope this helps.

### #4 xalu

Reputation: 0
• Posts: 10
• Joined: 14-October 08

## Re: Need some help with logic (hw question)

Posted 16 October 2008 - 07:52 AM

baavgai, on 14 Oct, 2008 - 01:05 PM, said:

Create a structure or class to hold the information you need. ( Not knowing what language you intend to use, it's hard to be specific. )

```typedef struct {
int studentId;
int classroom;
double  score;
} TestData;

```

Create an array of that type, or vector, or ArrayList. Collect the data. Then just write some functions to derive the information you need. You could write a loop that adds up all the scores for classroom X. Another that counts the current number of students, to validate the input data, etc.

There are more complex and possibly efficient ways to do this, but this approach would meet your requirements with minimal fuss.

Hope this helps.

Well the class is programming language so we arent working with any code yet. It is called pseudocode. The point is to just get the logic out. I looked at what you did and I don't understand it. We haven't working with structures unless a structure is an array. Basicaly its like flow charting with words that's what pseudocode is.

I haven't been able to get any further my self. just to show what we do looks like here is an example.

```Part A)

start
string idNumber
string firstName
string lastName
string major
num gpa
string HEADING="Students whoe G.P.A. is below 2.0"
string HEADING2="ID   First Names   Last Names   Major   G.P.A."
if gpa < then 2.0
print idNumber, firstNames, lastNames, major, gpa

stop

Part B)

start
string idNumber
string firstName
string lastName
string major
num gpa
string HEADING="Students whoe G.P.A. is below 2.0"
string HEADING2="ID   First Names   Last Names   Major   G.P.A."
string FOOTER="END OF FILE"
get idNumber, firstNames, lastName, major, gpa
while not eof
if gpa < 2.0 then
print idNumber, firstNames, lastNames, major, gpa
else
get idNumber, firstName, lastName, major, gpa
endwhile
print FOOTER
stop

Part C)

start
string idNumber
string firstName
string lastName
string major
num gpa
string HEADING2="Students whose major is English and G.P.A. is 3.5 or higher"
string HEADING3="ID   First Names   Last Names   Major   G.P.A."
get idNumber, firstNames, lastName, major, gpa
if major=english and gpa > 3.4 then
print idNumber, firstNames, lastNames, major, gpa
else
get idNumber, firstName, lastName, major, gpa
stop

```

I really appreciate any help with this. I am really stuck...and I think its probably something stupid I am getting confused about.

### #5 jill2873

Reputation: 0
• Posts: 1
• Joined: 28-August 09

## Re: Need some help with logic (hw question)

Posted 28 August 2009 - 07:00 PM

xalu, on 14 Oct, 2008 - 07:52 AM, said:

First off I want to say thank you so much for any help. This is my first class geared toward computer science and so far I have gotten it through and through. My professor is somewhat unavailble and I have been emailing him a lot so I figure I would look for some help.

I am trying to write in pseudocode. The chapter this assignment is in is titled arrays. I just can't figure out the array process. I understand what I need to do. I just can't seem to get it into a code.

Heres the assignment.

Quote

Watson Elementary School contains 30 classrooms numbered 1 through 30. Each classroom can contain any number of students up to 35. Each student takes an achievement test at the end of the school year and receives a score from 0 to 100. Write a program that accepts data for each student in the school - Student ID, classroom number, and score on the achievement test. Design a program that lists each classroom's average of the test scores.

This is as far as I can get.

```start
num studentId
num score
num numStudents
sting classSize=35
string class=1
string numClass=30
string average
get studentId, score, numStudens

```

I understand that I need to
1. get studens id for class 1, get number of students in that class.
2. get test scores for class 1
3. add all test scores then divide by number of students in the class...
4. print the average of the class.
5. repeat until class 30 is printed.

I just cant figure out the logic/pseudocode.

I really appreciate any help.

If this is the wrong place to post I am sorry...please let me know the correct place.

Did you ever figure out how to do this, I am having the same problem with the same assignment and my professor is unavailable, I would love it if you could help me a bit since you seem to have done this a while back.

### #6 syfran

• D.I.C Lover

Reputation: 83
• Posts: 1,103
• Joined: 12-July 09

## Re: Need some help with logic (hw question)

Posted 28 August 2009 - 08:11 PM

I'm sorry to say this, but the OP is not an active poster and probably will never visit this post again seeing as how it is nearly a year old..

Even if it he was active it would have probably been better to use a PM than dig up an old post.

This post has been edited by syfran: 28 August 2009 - 08:12 PM