• 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, yeah that makes sense. I have been in situations where I barely did not crush badly on the road due to other driver starting to change lanes into another car - freaked out last second and avoided it by crashing into the side of the bridge instead. i got away because I quickly changed lanes 2 times in a couple of second and unlike that idiot I did not lose control big part of this was my car was good 😊 (audi a7) vs the old van the crashed driver was driving would AI be able to react and quickly change lanes twice both time barely avoiding collision … I don’t know my car systems pumped the breaks and tried to warn me with a beep and vibration but if I slammed the breaks the car behind me would hit me then again I have BMW driver training and a good car - so I have no idea how robot taxi would react i am not sure extreme fast lane changes would be programmed in - it is dangerous as hell unless you are FULLY aware, and have done it before but it is a general risk to do it especially in the conditions with bad weather and when you are not driving a sports car with 4 wheel drive and very good control
    • PDF Arranger 1.12.1 by Razvan Serea PDF Arranger merges or splits PDF documents and rotates, crops and rearranges their pages using an interactive and intuitive graphical interface. It is a front end for pikepdf. It's available for Linux and Windows. PDF Arranger features: Merge double-sided scanned document Delete pages from a PDF file Rotate pages in a PDF file Merge multiple PDF documents Zoom in / out Export selected pages from a PDF Undo/redo support Duplicate PDF pages Crop white borders Supports importing encrypted PDF files Create a booklet from multiple pages Allow to edit Keywords, Subjects and dates in document info ...and more PDF Arranger 1.12.1 changelog: Fix incompatibility with Python 3.13.4 on Linux #1238 Update Dutch and Italian translation Download: PDF Arranger 1.12.1 | 42.6 MB (Open Source) Download: PDF Arranger Portable | PortableApps.com View: PDF Arranger Website | Other operating systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • If you can't sleep, work, or make out with your lady in the back of the car, then it isn't actually "full self driving"...and shouldn't be marketed lied about that way. It's actually just "driver assisted".
    • I’m happy to admit that I truly hate musk from the bottom of my heart. He provided me with PLENTY reasons.
    • AIMP 5.40 Build 2683 is out.
  • Recent Achievements

    • Collaborator
      CHUNWEI earned a badge
      Collaborator
    • Apprentice
      Cole Multipass went up a rank
      Apprentice
    • Posting Machine
      David Uzondu earned a badge
      Posting Machine
    • One Month Later
      Stokenking earned a badge
      One Month Later
    • One Month Later
      Kevin Jones earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      538
    2. 2
      ATLien_0
      262
    3. 3
      +Edouard
      193
    4. 4
      +FloatingFatMan
      177
    5. 5
      snowy owl
      135
  • Tell a friend

    Love Neowin? Tell a friend!