• 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

    • It has the same switch to allow whitelisting or not as the regular AdBlock extension.
    • These 20 crypto phishing applications are scamming Play Store users by Hamid Ganji Google Play Store is the main venue for Android users to download applications. While Google has strict rules and policies for verifying apps, some malicious apps somehow slip through anyway. Meanwhile, when it comes to crypto wallet apps, both Google app auditors and Play Store users need to be even more cautious. Cyble Research and Intelligence Labs has identified at least 20 crypto phishing applications on the Google Play Store that impersonate legitimate and popular crypto wallet apps and try to steal users' crypto credentials. By impersonation, these malicious apps trick users into downloading them and then start to capture the user's actual login data. "What makes this campaign particularly dangerous is the use of seemingly legitimate applications, hosted under previously benign or compromised developer accounts, combined with a large-scale phishing infrastructure linked to over 50 domains. This extends the campaign's reach and lowers the likelihood of immediate detection by traditional defenses." Cyble writes. Some of these malicious apps have the same name but come with a different package name. After removing duplicate names, here's the list of 9 newly discovered crypto phishing applications on the Play Store: Pancake Swap Suite Wallet Hyperliquid Raydium BullX Crypto OpenOcean Exchange Meteora Exchange SushiSwap Harvest Finance Blog According to Cyble, these apps prompt users to enter their 12-word mnemonic phrase to access the fake crypto wallet. Also, scammers use accounts that were previously used to distribute legitimate apps to minimize the risk of getting caught by Google. These accounts are more likely to be compromised and then taken over by scammers. If you've downloaded any of these fake crypto wallet apps from the Play Store, make sure to delete them as soon as possible. In 2024, revenue from crypto scams was estimated to be around $9.9 billion. This billion-dollar crypto scam business is expected to grow massively in 2025 thanks to AI.
    • Again...just because Microsoft never managed to be as successful as Google in that business that doesn't mean they are not exactly what Google is. An online advertising company. Edge's built in ad block in case you don't know whitelists their own advertising platform. According to Microsoft... Google ads and tracking bad, Microsoft ads and tracking good:)
  • Recent Achievements

    • Week One Done
      LunaFerret earned a badge
      Week One Done
    • Week One Done
      Ricky Chan earned a badge
      Week One Done
    • Week One Done
      maimutza earned a badge
      Week One Done
    • Week One Done
      abortretryfail earned a badge
      Week One Done
    • First Post
      Mr bot earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      483
    2. 2
      +FloatingFatMan
      264
    3. 3
      snowy owl
      239
    4. 4
      ATLien_0
      229
    5. 5
      Edouard
      179
  • Tell a friend

    Love Neowin? Tell a friend!