Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 finding highest and lowest marks out of the inputed marks
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
new




PostPosted: Tue Dec 21, 2004 4:07 am   Post subject: 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)


24-09-04_test marks.t
 Description:

Download
 Filename:  24-09-04_test marks.t
 Filesize:  2.25 KB
 Downloaded:  228 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Tue Dec 21, 2004 7:30 am   Post subject: (No subject)

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




PostPosted: Tue Dec 21, 2004 11:28 pm   Post subject: (No subject)

Pritty good, simple I may add though. You should've make it sorted itself, then shown them all.

code:

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




PostPosted: Wed Dec 22, 2004 8:16 am   Post subject: (No subject)

Artemis wrote:

% The more parametres you have (i.e. name, mark, class)
% You to repeat these three lines of code

Not necessarily. You can use records:
code:

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




PostPosted: Wed Dec 22, 2004 10:27 am   Post subject: (No subject)

You learn somthing new every day Razz
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: