major project algorithms (1 Viewer)

xeriphic

Member
Joined
May 7, 2004
Messages
452
Location
Sydney
i was just working on my algorithms for the major project, i was wondering if someone can take a look at this for me and tell me whether it's right or wrong, i'm not really good at algorithms, thanks

BEGIN MAINPROGRAM

INITIALISATION
get the book_details
set Conversion_Complete to FALSE
END INITIALISATION
WHILE Conversion_Complete = FALSE
use query search
IF exchange_details = TRUE THEN
calculate conversion
set Conversion_Complete = TRUE
ELSE
Conversion_Complete = FALSE
ENDIF
ENDWHILE
IF Conversion_Complete = TRUE THEN
report calculated conversion
ENDIF
END MAINPROGRAM

BEGIN SUBPROGRAM use query search
set exchange_details to FALSE
WHILE exchange_details = FALSE
input book_details
IF data is found THEN
exchange_details = TRUE
ELSE
exchange_details = FALSE
END IF
ENDWHILE
END SUBPROGRAM use query search

more to come, feel free to change the parts that doesn't make sense, which i'm sure there will be many
 
Last edited:

grendel

day dreamer
Joined
Sep 10, 2002
Messages
103
Gender
Male
HSC
N/A
BEGIN MAINPROGRAM

INITIALISATION
get the book_details
set Conversion_Complete to FALSE
END INITIALISATION
WHILE Conversion_Complete = FALSE
use query search
IF exchange_details = TRUE THEN
calculate conversion
set Conversion_Complete = TRUE
ENDIF
ENDWHILE
report calculated conversion
END MAINPROGRAM

BEGIN SUBPROGRAM use query search
set exchange_details to FALSE
WHILE exchange_details = FALSE
input book_details
IF data is found THEN
exchange_details = TRUE
END IF
ENDWHILE
END SUBPROGRAM use query search

you don't need to set your flags, Conversion_Complete and exchange_details to false in your loops as they are already initialised as false. not a mistake just redundant code.

also in main program, you don't need tat if-then statement as "Conversion_Complete" must be true as that is the exit condition of the loop.

not sure what your program is supposed to do, in your sub program should "input book details" be "get book details" or "read book details"??

get book details -> used for keyboard entry
read book details -> used when reading from data file.

don't you need to return exchange_details from your sub program? if exchange_details is a local variable then you need to pass it out as a parameter. if it is a global variable then that is not good form.

do you need the book details mentioned in your sub program to do "calculate conversion" in the main program? if you do then the book details should also be returne from your sub.
 

xeriphic

Member
Joined
May 7, 2004
Messages
452
Location
Sydney
thanks for the help, sorry if i'm abit too ambigous in the algorithm

for the redundant code, yea i wasn't sure whether to put it in or not, well i'll take it now then

i see what you meant about the IF statement, i'll fix it up

after reading the definition, it should be get book_details

i'll add the return bit, forgot i guess

the book_details isn't required for the calculation conversion, basically the book details is needed to input into the database query so it can retrieve the cost details which will be used for the calculate conversion

appreciated your help, new changes made now
 

dark`secrets

<insert title>
Joined
Dec 23, 2003
Messages
2,702
Gender
Undisclosed
HSC
N/A
grendel took forever to type it up!!
i was next to him.
 

dark`secrets

<insert title>
Joined
Dec 23, 2003
Messages
2,702
Gender
Undisclosed
HSC
N/A
Originally posted by xeriphic
really, once again i'm grateful that you can help in checking my algorithms
im kidding dude. He loves doing it.
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
from the above algorithmn it would be a better idea naming sub programs using conventions that joins the name of the sub program together for example "use query search" should really be "QuerySearch"

and when you invoke this sub program it MUST be underlined, it's some sort of convention that shows that you're invoking a sub program so you should have this QuerySearch .
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top