Hi all! (if this is not the correct forum to post my question please move it to the appropriate one)

I have an assignment which requires writing a pseducode from a statement writting in English. Man! this psuedocode thing is really difficult to write . Easy to follow if you are writing a code from it though!

My problem is that the statement is completely unrelated to algorithm. It's to write a program - web apllication actually.

I hope you could answer my questions below.

Let's assume I'm asked to write the following pseudocode for a simple courses files search website (completely unrelated to my assignment, in fact my assignment is more comlicated)

After a member is logged in, the system will ask him to enter the course ID and the name of the course he want to search in the website. The member could skip this step and click search and the system will display all courses files.

How am I exactly going to write this? how exactly I write that there is 2 parameters should be entered by the member? or just click the search button? My try is below and I'm sure it's compltely incorrect.

If member is_Loggedin 
    system DISPLAY search_box
    member ENTERES course_id AND course_name
    IF system FOUND (entered parameters)/(required course_id AND course_name)
        system list course files
        ELSE
        system prompts error entered course is not found
        ENDIF 
    ELSE
        system list all courses files
    ENDIF 
ELSE
system prompts for login information
ENDIF

Please guid me thru what keywords should be used instead of what I used above in my attempt. Please remember my assignment is irrevelent to this example. It asks for login and many parameters to be entered so I made up a fast example which asks for the same stuff my assignment asks.

Thanks Dani's!!

Recommended Answers

All 8 Replies

how exactly I write that there is 2 parameters should be entered by the member? or just click the search button?

I'd break the logic down like this:

If NOT empty(course_id)
    search_exact(course_id)
Else If NOT empty(course_name)
    search_fuzzy(course_name)
Else
    list_all()

If there's a course ID, it's safe to assume that the ID is unique and you can find either an exact match or the course doesn't exist. Otherwise, if there's a course name you could potentially find multiple courses with matching or similar names which may result in no matches. Finally, if you have neither an ID nor a name, list all active courses.

To be more generic: unique keys can short circuit the algorithm because a unique key will give you an exact match. Non-unique keys could return multiple results and come next. Lastly, no valid input is either an error or matches everything, depending on your needs.

Please guid me thru what keywords should be used instead of what I used above in my attempt.

Pseudocode has no rules. Unless you've been given a specific set of keywords that are allowed, just do what makes sense to you and is logically consistent.

Thank you so much for your input admin :)

I think after showing this post and showing my work and yours to my instructor I got the idea.

One question I have tho, let's say I want to show a calender of free dates available. How would I write the calender as a pseudocode? complete writing ? or assume the calender() method is already exists ? and it returns or display all the free available ? because I think writing a whole calender methis is way too much.

Note: the assignment is not mainly to make a calender psuedocode . The calender is just part of it. So that maybe I don't have to write it?

thanks!

How would I write the calender as a pseudocode? complete writing ? or assume the calender() method is already exists ?

If it's an extraneous utility that's not related to the logic you're trying to outline, just pretend a function already exists that does the work. If the calendar logic is what you're trying to outline, you need to write it. Pseudocode works much like flowcharting. If you have an operation that's not really necessary to flowchart in detail, you just leave it as an execution block, right? It's the same with pseudocode and "magic" functions; they're just placeholders.

Thank you so much!

Another question if possible, what about if I'm going to get some query from database? do I have to just write it like the following:

RETRAIVE courses list from database

Another example I did below

RETRAIVE      instructor courses from database using his username
or
DISPLAY getAllcourses(username)

Which one is better?

I'm sorry if i'm asking too many silly questions, I'm getting better in writing the assignment now, but each time I suspect something I try to write it hear.

Yes, that's fine.

AAAH thanks so much! I updated my previous reply by the way? are you aware of that?

I updated my previous reply by the way? are you aware of that?

Ninja updates should be expected to go unnoticed. But to answer your update, pick whatever you want. This is pseudocode, it doesn't matter.

Yeah sorry :)
Thanks so so so much!!
Really appreciate it Deceptikon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.