
-----------------------------------
new
Tue Dec 21, 2004 4:07 am

finding highest and lowest marks out of the inputed marks
-----------------------------------
this programs gets imput (teacher name, sudent name and thier marks then save it, then finds highest and lowest)

-----------------------------------
Cervantes
Tue Dec 21, 2004 7:30 am


-----------------------------------
Not bad, but you should do some error trapping to make sure the input (for the marks) is between 0 and 100.  
Also, there's really now need to make a procedure with no parameters called into and then call it immediately after making the procedure.  If you want to title that group of code as the introduction, just use comments :wink:

-----------------------------------
Artimes
Tue Dec 21, 2004 11:28 pm


-----------------------------------
Pritty good, simple I may add though. You should've make it sorted itself, then shown them all.


for decreasing i : (arraySize - 1) .. 1
    for j : (arraySize - 1) .. 19
        if (markStudent (j) > markStudent (j + 1)) then
           
            % Change variable to choose what you sort by
            % > Sort from greatest to least
            % < Sort from least to greatest
            
            intTemp := markStudent (j)
            markStudent (j) := markStudent (j + 1)
            markStudent (j + 1) := intTemp

            stringTemp := nameStudent (j)
            nameStudent (j) := nameStudent (j + 1)
            nameStudent (j + 1) := stringTemp
            
            % The more parametres you have (i.e. name, mark, class)
            % You to repeat these three lines of code
        end if
    end for
end for



-----------------------------------
Cervantes
Wed Dec 22, 2004 8:16 am


-----------------------------------

            % The more parametres you have (i.e. name, mark, class)
            % You to repeat these three lines of code 

Not necessarily.  You can use records:

var howmany : int
put "How many students? " ..
get howmany
var student : array 1 .. howmany + 1 of %the +1 will be used as a temporary holder
    record
        mark : int
        name : string
    end record
for i : 1 .. howmany
    student (i).mark := Rand.Int (0, 100)
    student (i).name := chr (Rand.Int (65, 90)) %yes, their names are actually letters.
end for

for decreasing i : (howmany - 1) .. 1
    for j : 1 .. (howmany - 1)
        if (student (j).mark > student (j + 1).mark) then

            % Change variable to choose what you sort by
            % > Sort from greatest to least
            % < Sort from least to greatest

            %make the entire record equal to a different element of that record
            student (howmany + 1) := student (j)
            student (j) := student (j + 1)
            student (j + 1) := student (howmany + 1)

        end if
    end for
end for
for i : 1 .. howmany
    locate (i, 1)
    put student (i).name
    locate (i, 6)
    put student (i).mark
end for


-----------------------------------
Artimes
Wed Dec 22, 2004 10:27 am


-----------------------------------
You learn somthing new every day :P
