Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,230 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,292 people online right now. Registration is fast and FREE... Join Now!




Need some help with logic (hw question)

 
Reply to this topicStart new topic

Need some help with logic (hw question), I can't figure out how to work with arrays

xalu
14 Oct, 2008 - 07:52 AM
Post #1

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 2

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.

CODE
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 am really stuck...any advice?

I really appreciate any help.


If this is the wrong place to post I am sorry...please let me know the correct place.
User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: Need Some Help With Logic (hw Question)
14 Oct, 2008 - 10:37 AM
Post #2

I vill break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,393



Thanked: 6 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

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



User is offlineProfile CardPM
+Quote Post

baavgai
RE: Need Some Help With Logic (hw Question)
14 Oct, 2008 - 12:05 PM
Post #3

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,019



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
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. )

cpp

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.

User is offlineProfile CardPM
+Quote Post

xalu
RE: Need Some Help With Logic (hw Question)
16 Oct, 2008 - 06:52 AM
Post #4

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 2

QUOTE(baavgai @ 14 Oct, 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. )

cpp

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.


CODE
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."
    print HEADING
    print HEADING2
        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"
    print HEADING
    print HEADING2
    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 HEADING=" Literary Honor Society"
    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."
    print HEADING
    print HEADING2
    print HEADING3
    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.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:14AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month