Kerberonix Posted March 1, 2014 Share Posted March 1, 2014 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 Memberif person EQUALS >= 18PRINT "Accepted"ELSEPRINT "Underage"End ifELSEPRINT "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 Share on other sites More sharing options...
0 Andre S. Veteran Posted March 1, 2014 Veteran Share Posted March 1, 2014 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. Kerberonix 1 Share Link to comment Share on other sites More sharing options...
0 Kerberonix Posted March 1, 2014 Author Share Posted March 1, 2014 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 Share on other sites More sharing options...
0 +theblazingangel MVC Posted March 1, 2014 MVC Share Posted March 1, 2014 For your exam... So are your posting this question during it??? 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! Ahh I see, So it could be IF person = Member IF person >=18 PRINT "Accepted" etc Thank you! No, see above! Link to comment Share on other sites More sharing options...
0 Kerberonix Posted March 1, 2014 Author Share Posted March 1, 2014 For your exam... So are your posting this question during it??? 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 Share on other sites More sharing options...
Question
Kerberonix
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
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
Share on other sites
4 answers to this question
Recommended Posts