• 0

Pseudo code


Question

Hello, this is for my AS Computing exam

 

My teacher is fairly clueless so I was just wondering if this is correct?

 

It's about Nested Statements

 

Write your own nested statement in pseudo code to print ?Accepted? if someone is a member and

over 18, ?Not a member? if they are not a member or ?Underage? if they are not 18.

 

if person EQUALS Member

if person EQUALS >= 18

PRINT "Accepted"

ELSE

PRINT "Underage"

End if

ELSE

PRINT "not a member"

End if

 

Im mostly concerned about if this is in the right format, should the ELSE PRINT "not a member" come last? and is >= appropriate for pseudo code?

 

Thanks in advance

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

That looks correct, with the exception that "EQUALS >=" is nonsense, either write "greater than or equal" or ">=", but not both.

 

Pseudo-code has no formal rules, just keep it consistent. For instance some of your keyword are all-caps and some aren't, that's not good. Pick a style and stick with it.

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288845
Share on other sites

  • 0
  On 01/03/2014 at 16:38, Andre S. said:

That looks correct, with the exception that "EQUALS >=" is nonsense, either write "greater than or equal" or ">=", but not both.

 

Pseudo-code has no formal rules, just keep it consistent. For instance some of your keyword are all-caps and some aren't, that's not good. Pick a style and stick with it.

 

Ahh I see,

 

So it could be

 

IF person = Member

IF person >=18

PRINT "Accepted"

etc

 

Thank you!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288857
Share on other sites

  • 0

For your exam... So are your posting this question during it??? huh.png

 

Your answer looks pretty good to me, the only thing I would change (apart from consistency of capitals) is the use of the word "EQUALS". A person is a person, a person does not equate directly to a membership status or a number. This would be better:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    Else

        PRINT "Underage"

    End if

Else

    PRINT "Not a member"

End if

Rules on pseudo code are pretty lax, as long as the logic is sound and it makes sense, it really doesn't matter too much. With specific regard to use of '>=' and similar expressions, think about who will be reading the pseudo code you've written (I'm talking in general here, not specifically about the exam). If you're writing it just for yourself or for others who understand programming, it's obviously going to be fine; whereas if someone unfamiliar with programming were to need to look at it, who may perhaps be unfamiliar with the expression you are intending on using, it may be best to revert to words to avoid confusion.

 

The order of conditional checks in your logic is perfectly sound. If you were to attempt to follow the precise order of logical requirements in the question, you may end up with this:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    End if

Else, if person is not a member

    PRINT "Not a member"

Else, if age of person less than 18

    PRINT "Underage"

End if

Which would be incorrect because the logic does not actually work!


  On 01/03/2014 at 16:46, Kerberonix said:

Ahh I see,

 

So it could be

 

IF person = Member

IF person >=18

PRINT "Accepted"

etc

 

Thank you!

 

No, see above!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288859
Share on other sites

  • 0
  On 01/03/2014 at 16:49, theblazingangel said:

For your exam... So are your posting this question during it??? huh.png

 

Your answer looks pretty good to me, the only thing I would change (apart from consistency of capitals) is the use of the word "EQUALS". A person is a person, a person does not equate directly to a membership status or a number. This would be better:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    Else

        PRINT "Underage"

    End if

Else

    PRINT "Not a member"

End if

Rules on pseudo code are pretty lax, as long as the logic is sound and it makes sense, it really doesn't matter too much. With specific regard to use of '>=' and similar expressions, think about who will be reading the pseudo code you've written (I'm talking in general here, not specifically about the exam). If you're writing it just for yourself or for others who understand programming, it's obviously going to be fine; whereas if someone unfamiliar with programming were to need to look at it, who may perhaps be unfamiliar with the expression you are intending on using, it may be best to revert to words to avoid confusion.

 

The order of conditional checks in your logic is perfectly sound. If you were to attempt to follow the precise order of logical requirements in the question, you may end up with this:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    End if

Else, if person is not a member

    PRINT "Not a member"

Else, if age of person less than 18

    PRINT "Underage"

End if

Which would be incorrect because the logic does not actually work!

 

No, see above!

I looked at a few similar questions against the mark scheme and some of them allow the use of expressions, but some of them don't even list them... but they all include the use of words such as the ones you used. So the safe option is to write it to a standard (like you did with actually writing "greater than" etc) which everyone may be able to read, which is what I shall do from now on.

 

And my exam isn't until the end of june :p

 

Thank you!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288919
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I see the Winblows 11 BETA testing continues. This is just Windows 10 all over again. Oh well, everything is still smooth sailing over here on Windows 10 21H2 LTSC. You unpaid sheep BETA testers be sure to let us know when you get done BETA testing Winblows 11 for the rest of us. 🤣
    • What do you expect? Windows 11 is still in BETA. This is Windows 10 all over again. M$ doesn't hire people to do BETA testing anymore. They just let all the dumb sheep with FOMO do all the BETA testing for them. It's the same dumb sheep who use self-checkout at the store and do someone else's job for FREE! All while the worker who's getting paid just stands there and watches them. 🤣 🤡
    • Pet peeve: Microsoft using scaling options to get around the fact they removed font size settings, as if that's somehow acceptable to do. Thankfully third party apps still can adjust font sizes just fine, even though it often randomly resets on OS updates. And the funny thing is that not only are the scaling options horrible crutches, but they only work in some applications. And, ironically enough, even some apps from Microsoft themselves have hardcoded tiny fonts in certain dialogs in them. Example - certain parts of MS Office apps UI.
    • Unofficial script does the most useful official Windows 11/10 repairs you want automatically by Sayan Sen IT admins and system admins, and even home users have to run various Windows diagnostic runs from time to time in order to iron out or work around system problems. Last year, Microsoft published a guidance piece about various such native Windows apps, tools and utilities they include the like of Task Manager, Registry Editor, and more. Aside from them, Windows also comes with SFC (System File Checker) and DISM (Deployment Image Servicing and Management) to scan and fix corrupt and missing system files. Besides those, various other ways to help and diagnose network issues related to DNS (Domain Name System), among others, also exists. In order to save time running these, a Reddit user has created a new tool that automates all of these into a single package. The author writes that the Batch script (.BAT file) they have developed is "basically a one-stop script that can help clean up your system, run built-in diagnostics, fix common network issues, and generate system reports." The script is based on native Windows tools like netsh, ipconfig, systeminfo, among others, and the idea behind this is essentially to save time. The tool can be of help with Windows Update repairs, among others, something we all know is pretty common, and even Microsoft's own support articles may not prove to be helpful. Here is everything the utility can do for you: Run SFC, DISM, CHKDSK from a single menu Restart network adapters with auto-detection Flush or set DNS (Google, Cloudflare, or custom) Windows Update repair (resets services + cache) Generate system reports (saved as .txt files on Desktop) Show installed drivers Clean up temp files Registry backup and restore (manual) The latest version of the utility is now available for download on GitHub. The new version fixes issues related to admin privileges. As the script requires it to be run as an admin, it now restart itself to work in admin mode even if a user forgot to run it as an administrator. To download it, head over to its GitHub page here. The utility is named Windows Maintenance Tool. As always, though, make sure to back up your PC as this is an unofficial third-party app, and it's better if you test it first in a VM. Source: Lil_Batti (Reddit)
    • Come the hell on, do we need clickbait titles? "Overwatch 2" - 11 characters "a popular multiplayer hero shooter" - 34 characters What's the purpose here - delivering news or titles for clicks? I think we all know the answer. You're straying into "Number 7 on this list will SHOCK you" territory and while it may work on some crappy sites, this is why they are crappy sites. Just tell the story! Go back and look at popular articles that made Neowin what it was. Did they have headlines of "New OS from major technology conglomerate has astonishing new feature" or is it likely to tell the story succinctly and then elaborate within the content?
  • Recent Achievements

    • One Month Later
      CoolRaoul earned a badge
      One Month Later
    • First Post
      Kurotama earned a badge
      First Post
    • Collaborator
      Carltonbar earned a badge
      Collaborator
    • Explorer
      MusicLover2112 went up a rank
      Explorer
    • Dedicated
      MadMung0 earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      ATLien_0
      270
    3. 3
      +FloatingFatMan
      245
    4. 4
      +Edouard
      201
    5. 5
      snowy owl
      168
  • Tell a friend

    Love Neowin? Tell a friend!