5 Replies - 3928 Views - Last Post: 01 May 2009 - 07:18 AM

#1 JamesConley   User is offline

  • D.I.C Regular
  • member icon

Reputation: 19
  • View blog
  • Posts: 341
  • Joined: 09-March 09

Advanced Array Manipulation

Posted 28 April 2009 - 02:55 PM

Hey everyone!! So, this is what I'm working with (school problem). An application in which I have to design that allows a professor to enter a student name and 10 quiz scores for each of the 20 students. The putput lists each students name and total points for each students eight highest-scoring quizzes.

This is what I developed so far. My real problem is listing the eight highest scores, which i have yet to add. I'm just looking for people to take a look at it and if you see something I can correct or possibly teach me a better way to do it that would be great. Again, I am not looking to have the answer handed to me that's not why I am here, I am looking for any help that is offered so that one day I can return those favors to aspiring programmers like myself.
	 Start

			string name
			num  students = 21
			num quizScore [students]
			num x = 1 
				   get name
						while x < students
				get quizScore [x]
				 x=x +1 
endwhile
		perform BubbleSort (num quizScore[], num students)
		DisplayArray (num quizScore[], num students)
Stop

void BubbleSort (num quizScore[], num students)

void DisplayArray(num quizScore[], num students)
	num x = students – 1 
	while x > 0 
		print name, quizScore[x]
		x = x – 1 
	endwhile
return


Thanks for all of your time!!!! Much appreciated!!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Advanced Array Manipulation

#2 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Advanced Array Manipulation

Posted 29 April 2009 - 05:16 PM

View Postjpconleyiv, on 28 Apr, 2009 - 01:55 PM, said:

Hey everyone!! So, this is what I'm working with (school problem). An application in which I have to design that allows a professor to enter a student name and 10 quiz scores for each of the 20 students. The putput lists each students name and total points for each students eight highest-scoring quizzes.

This is what I developed so far. My real problem is listing the eight highest scores, which i have yet to add. I'm just looking for people to take a look at it and if you see something I can correct or possibly teach me a better way to do it that would be great. Again, I am not looking to have the answer handed to me that's not why I am here, I am looking for any help that is offered so that one day I can return those favors to aspiring programmers like myself.
	 Start

			string name
			num  students = 21
			num quizScore [students]
			num x = 1 
				   get name
						while x < students
				get quizScore [x]
				 x=x +1 
endwhile
		perform BubbleSort (num quizScore[], num students)
		DisplayArray (num quizScore[], num students)
Stop

void BubbleSort (num quizScore[], num students)

void DisplayArray(num quizScore[], num students)
	num x = students – 1 
	while x > 0 
		print name, quizScore[x]
		x = x – 1 
	endwhile
return


Thanks for all of your time!!!! Much appreciated!!!!


I think you would want a 2D array like this:

num quizscores[number of students][number of quizzes]



for the quiz scores and just a single dimension array for the names

string students[number of students]



To read in the information you would need two nested loops. The outer one would count the number of students and the inner one would count the number of quizzes.

num x = 1
num y = 1
while x < number of students + 1
	while y < number of quizzes + 1
		y = y + 1
	end while
	x = x + 1
end while



That should help you get started. If you have further problems just leave a post about what you are unclear about.
Was This Post Helpful? 1
  • +
  • -

#3 JamesConley   User is offline

  • D.I.C Regular
  • member icon

Reputation: 19
  • View blog
  • Posts: 341
  • Joined: 09-March 09

Re: Advanced Array Manipulation

Posted 29 April 2009 - 06:27 PM

Ok so this what I have worked out since the last post, Thank you SixOfEleven. What I am still racking on are these few things.
1. Is my variable declared correctly- string name [num students]
2.Is it ok to initiate quizzes to 0
3. After the two nested loops, and once in the display module how do I set it up to know what the eight highest score are. At the end it has to print students name, and the total points for each students eight highest scoring quizzes.


Start

string name [num students]
num  students = 21
num quizzes = 0
num quizScore [num students] [num quizzes]
num x = 1 
num y = 1
	get name, quizScore
while x < students + 1
	while y < quizzes + 1
y = y + 1
endwhile
		x=x +1 
	endwhile

perform BubbleSort (num quizScore[], num students)
DisplayArray (num quizScore[], num students)
Stop

void BubbleSort (num quizScore[], num students)

void DisplayArray(num quizScore[], num students)
	num x = students – 1 
	while x > 0 
		print name, quizScore[x]
		x = x – 1 
	endwhile
return


Thanks Again!!!!
Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Advanced Array Manipulation

Posted 29 April 2009 - 06:48 PM

View Postjpconleyiv, on 29 Apr, 2009 - 05:27 PM, said:

Ok so this what I have worked out since the last post, Thank you SixOfEleven. What I am still racking on are these few things.
1. Is my variable declared correctly- string name [num students]
2.Is it ok to initiate quizzes to 0
3. After the two nested loops, and once in the display module how do I set it up to know what the eight highest score are. At the end it has to print students name, and the total points for each students eight highest scoring quizzes.


Start

string name [num students]
num  students = 21
num quizzes = 0
num quizScore [num students] [num quizzes]
num x = 1 
num y = 1
	get name, quizScore
while x < students + 1
	while y < quizzes + 1
y = y + 1
endwhile
		x=x +1 
	endwhile

perform BubbleSort (num quizScore[], num students)
DisplayArray (num quizScore[], num students)
Stop

void BubbleSort (num quizScore[], num students)

void DisplayArray(num quizScore[], num students)
	num x = students – 1 
	while x > 0 
		print name, quizScore[x]
		x = x – 1 
	endwhile
return


Thanks Again!!!!


You are getting closer but not quite. The order of your variables is a little wrong and the declaration is not quite right. You would want to put them like this:

num  students = 20
num quizzes = 10
string name [students]
num quizScore [students] [quizzes]



Your while loops are not quite right either, I admit I omitted something in my previous post you need to set y = 1 before you start the inner loop. You would want something along this lines:

while x < students + 1
		get name[x]
		y = 1
	while y < quizzes + 1
			get quizScore[x][y]
			y = y + 1
		endwhile
		x=x +1 
endwhile



Can you see why you would want to do that?

After you do that you will want to make a second loop that would go through each student, copy their scores to an array, sort that array and display the results. From what I've shown you see if you can figure it out. If you can't feel free to leave another post and I'll try and help you out. :)
Was This Post Helpful? 0
  • +
  • -

#5 JamesConley   User is offline

  • D.I.C Regular
  • member icon

Reputation: 19
  • View blog
  • Posts: 341
  • Joined: 09-March 09

Re: Advanced Array Manipulation

Posted 01 May 2009 - 07:05 AM

I GOT IT!!!!! I think.......Lol
Check it out SixOfEleven!!!!!!

num  students = 21
num quizzes = 11
string name [students]
num quizScore [students] [quizzes]
num x = 1 
num y = 1

while x < students 
		get name[x]
		y = 1
	while y < quizzes 
			get quizScore[x][y]
			y = y + 1
		endwhile
		perform BubbleSort (num quizScore[][])
		x=x +1
endwhile

DisplayArray (num quizScore[][], string name[])

Stop

void BubbleSort (num quizScore[][])

void DisplayArray(num quizScore[][], string name[])
 num v = 3
 num y
 num quizzes = 11
 num TotalScore = 0
 num students = 21
	y = 1
		  while y < students
	  while v < quizzes 
TotalScore = TotalScore + quizScore[y][v]
	  v=v + 1
endwhile
print name[y], TotalScore
y = y + 1
v = 3 
endwhile
return 



Tell me what you think, this is what I turned in.
Was This Post Helpful? 0
  • +
  • -

#6 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Advanced Array Manipulation

Posted 01 May 2009 - 07:18 AM

View Postjpconleyiv, on 1 May, 2009 - 06:05 AM, said:

I GOT IT!!!!! I think.......Lol
Check it out SixOfEleven!!!!!!

num  students = 21
num quizzes = 11
string name [students]
num quizScore [students] [quizzes]
num x = 1 
num y = 1

while x < students 
		get name[x]
		y = 1
	while y < quizzes 
			get quizScore[x][y]
			y = y + 1
		endwhile
		perform BubbleSort (num quizScore[][])
		x=x +1
endwhile

DisplayArray (num quizScore[][], string name[])

Stop

void BubbleSort (num quizScore[][])

void DisplayArray(num quizScore[][], string name[])
 num v = 3
 num y
 num quizzes = 11
 num TotalScore = 0
 num students = 21
	y = 1
		  while y < students
	  while v < quizzes 
TotalScore = TotalScore + quizScore[y][v]
	  v=v + 1
endwhile
print name[y], TotalScore
y = y + 1
v = 3 
endwhile
return 



Tell me what you think, this is what I turned in.


Looks like it would work. Good job. :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1