0

Hello everyone, I need a little help understanding what to do for a final project. I'm writing a program that will make an array for 10 songs, sort them by title, genre, and artist name, and make a hierarchy chart showing the branch of modules.

I understand this for the most part, but I'm having a little trouble writing the string values, and how to pass it through the sorting array with the numberOfEls value to make it more adjustable. Any help would be greatly appreciated, thanks alot.

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by TheArchitect
0

Hello everyone, I need a little help understanding what to do for a final project. I'm writing a program that will make an array for 10 songs, sort them by title, genre, and artist name, and make a hierarchy chart showing the branch of modules.

I understand this for the most part, but I'm having a little trouble writing the string values, and how to pass it through the sorting array with the numberOfEls value to make it more adjustable. Any help would be greatly appreciated, thanks alot.

In which language? Or does that matter? and do you want the full solution?

0

In which language? Or does that matter? and do you want the full solution?

Its actually pseudocode, the basic language to programming, I'm taking this class before Programming I, so this is before C++,C#, Java, and VB. Any help is appreciated.

0

Its actually pseudocode, the basic language to programming, I'm taking this class before Programming I, so this is before C++,C#, Java, and VB. Any help is appreciated.

What pseudo code do you have so far? Also, how are you "having trouble writing the strings" when this is pseudo code? All pseudo code is is a description (including some sample code with comments) of what you eventually want the program to do. Saying you are having trouble writing strings and passing strings through arrays sounds like you're describing programming challenges.

0

What pseudo code do you have so far? Also, how are you "having trouble writing the strings" when this is pseudo code? All pseudo code is is a description (including some sample code with comments) of what you eventually want the program to do. Saying you are having trouble writing strings and passing strings through arrays sounds like you're describing programming challenges.

start
num SIZE = 10
num score
string artistName
string songGenre
string songTitle
numberOfEls = fillArray (score, SIZE)
sortArray (score, numberOfEls)
displayArray (score, numberOfEls)
stop

num fillArray (num score[], num SIZE)
num x = 0
num limit = SIZE – 1
get score [x]
while not eof AND x < limit
x = x + 1
get score [x]
endwhile
return x

void sortArray (num score[], num els)
num x = 0
num y = 0
num COMPS = els – 1
while y < COMPS
x = 0
while x < COMPS
if score [x] > score [x + 1] then
swap (score, x)
endif
x = x + 1
endwhile
y = y + 1
endwhile
return

void swap (num score [], num x)
num temp
temp = score [x + 1]
score [x + 1] = score [x]
score [x] = temp
return

void displayArray (num score [], num els)
num x = 0
while x < els
print score [x]
x = x + 1
endwhile
return

Okay, so basically.. I'm trying to pass the strings through the array and sort them. Thats what I have so far. My question is, A. Are the string values at the top valid, and assigned correctly? B. Do I need to have three different sorting loops for each of the strings?

EDIT - The post changed the indentation, but I did in fact indent it accordingly on my document.
EDIT EDIT - I need to get this finished by the 4:30 PM EST, so any prompt help would be massively appreciated, thank you for helping thus far Architect.

Edited by Arikado.Kanchi: n/a

0

start
num SIZE = 10
num score
string artistName
string songGenre
string songTitle
numberOfEls = fillArray (score, SIZE)
sortArray (score, numberOfEls)
displayArray (score, numberOfEls)
stop

num fillArray (num score[], num SIZE)
num x = 0
num limit = SIZE – 1
get score [x]
while not eof AND x < limit
x = x + 1
get score [x]
endwhile
return x

void sortArray (num score[], num els)
num x = 0
num y = 0
num COMPS = els – 1
while y < COMPS
x = 0
while x < COMPS
if score [x] > score [x + 1] then
swap (score, x)
endif
x = x + 1
endwhile
y = y + 1
endwhile
return

void swap (num score [], num x)
num temp
temp = score [x + 1]
score [x + 1] = score [x]
score [x] = temp
return

void displayArray (num score [], num els)
num x = 0
while x < els
print score [x]
x = x + 1
endwhile
return

Okay, so basically.. I'm trying to pass the strings through the array and sort them. Thats what I have so far. My question is, A. Are the string values at the top valid, and assigned correctly? B. Do I need to have three different sorting loops for each of the strings?

EDIT - The post changed the indentation, but I did in fact indent it accordingly on my document.
EDIT EDIT - I need to get this finished by the 4:30 PM EST, so any prompt help would be massively appreciated, thank you for helping thus far Architect.

Yes you do have to have 3 different sorting loops for each of the sorting criteria or have a subroutine that takes in a sort criteria and does sorting based on that field, sorting first by title, then again by genre, and finally by artist name. The above looks pretty good except I see that in your sorting loop you don't use the y index

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.