Need some help with logic (hw question)

I can't figure out how to work with arrays

Page 1 of 1

5 Replies - 5494 Views - Last Post: 28 August 2009 - 08:11 PM Rate Topic: -----

#1 xalu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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 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.

Is This A Good Question/Topic? 0
  • +

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

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5805
  • View blog
  • Posts: 12,644
  • 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.
Was This Post Helpful? 0
  • +
  • -

#4 xalu  Icon User is offline

  • New D.I.C Head

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

Re: Need some help with logic (hw question)

Posted 16 October 2008 - 07:52 AM

View Postbaavgai, 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."
	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.
Was This Post Helpful? 0
  • +
  • -

#5 jill2873  Icon User is offline

  • New D.I.C Head

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

Re: Need some help with logic (hw question)

Posted 28 August 2009 - 07:00 PM

View Postxalu, 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 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.

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.
Was This Post Helpful? 0
  • +
  • -

#6 syfran  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1