I have gotten stuck on a computer science assignment regarding Pseudocode and need a little help if possible. The task requires me to scan the ID of multiple people trying to enter a club and then compare there features (eye colour, hair colour etc) to the picture on the ID. If there is a match then they are allowed to enter but if more than two features do not match then they are denied. Any help would be amazing. Thanks
p.s they are all entering 1 by 1 scanning each member to their respective ID

Recommended Answers

All 12 Replies

Show us what you have tried for yourself first.

What ddanbe said, nobody knows what help you need until you show us where you are getting stuck. You need to post your code (or pseudocode) as is, and explain the problems you are having.

Hey thanks for the reply,
Really lost so looking for any help

ID_CHECK
PRINT 'camera photo'
PRINT 'ID photo'
READ 'camera photo' features FROM 'ID photo'
IF 'camera photo' features match 'ID photo' features Then
PRINT 'succeed'
ELSE
PRINT 'fail'
ENDIF
END

I understand i will probably have to use repeition statements and run through each feature seperatly, but I'm not even sure I'm using the basic statments in the right place.
Cheers

I'm just lost on how to approach the question, it's not really an assignment more just the weekly work, but want to be able to understand what to do so i can keep moving forward, and comparing data in pseudo has really got me stuck

Any better or am i way off, any help greatly appreciated

ID_CHECK    
Have the passenger insert ID into the machine
GET ID
CASE EYE_COLOUR_A   
  value1 : blue
  value2 : brown
  value3 : green
  OTHER : unknown
 WRITE EYE_COLOUR_A
 ENDCASE
 CASE HAIR_COLOUR_A  
   value1 : brown  
   value2 : blonde
   value3 : red
   value4 : grew
   value5 : black 
   value6 : unknown
 WRITE HAIR_COLOUR_A
 ENDCASE
 CASE SKIN_COLOUR_A  
  value1 : light  
   value2 : medium
   value3 : dark 
   value6 : unknown
 WRITE SKIN_COLOUR_A
 ENDCASE

PASSENGER_CHECK
Have passenger stand infront of camera
GET passenger photo
CASE EYE_COLOUR_B       
  value1 : blue
  value2 : brown
  value3 : green
  OTHER : unknown
 WRITE EYE_COLOUR_B
 ENDCASE
IF EYE_COLOUR_A = EYE_COLOUR_B THEN 
PRINT match
  ELSE
 PRINT no-match
        ENDIF
CASE HAIR_COLOUR_B
  value1 : brown  
  value2 : blonde
  value3 : red
  value4 : grew
  value5 : black 
  value6 : unknown
WRITE HAIR_COLOUR_B
ENDCASE
IF HAIR_COLOUR_A = HAIR_COLOUR_B THEN   
  PRINT match
    ELSE
  PRINT no-match
 CASE SKIN_COLOUR_B  
   value1 : light  
   value2 : medium
   value3 : dark 
   value6 : unknown
  WRITE SKIN_COLOUR_B
  ENDCASE
  IF SKIN_COLOUR_A = SKIN_COLOUR_B THEN   
  PRINT match
    ELSE
   PRINT no-match  
  IF no-match <2
    PRINT denied 
    ELSE
        PRINT success
    ENDIF
    END

Definitely better.
Pseudo-cde is for explaining algorithms, flow of control etc, so you don't need quite so much detail, and you can make up you own "syntax", eg:

GET passenger photo 
get eye color from photo (one of blue. brown, green, unknown)
get hair color from photo (one of etc
if eye color and hair color both match the id then passenger is matched, otherwize passenger is denied

details like switch don't belong here unless you are making a point about exactly how to get the color.

Thanks a heap appreciate it,
Do I have to put the colors into categorys or can i just have them in brackets next to the GET command?

There is no universal standard for writing pseudo-code. It's up to you to chose whatever words you like to explain the algorithm or process you are trying to document. Use brackets where they help make things clear.
A lot depends on the level of detail... if you are explaining some technical detailed thing (eg compressing audio data into an mp3) the you will probably be careful about showing all the exact scope of loops and if tests. If you are explaining a business process that going to be automated, then a much higher-level syntax would be appropriate.

In this case you are getting hair color from a photo. You don't need to explain how to do that yet, but it helps if you show what kind of detail you need... just quick blond/brown/black categorisation, or much finer detail... what about people with streaks of a different color... etc By saying one of black/brown/blondyou are telling the reader all they need to know for the moment. Exactly how you say that doesn't matter as long as its clear to the reader.

Thanks a lot, been a massive help, all still extremely new to me.
As a quick final are you able to look at what I have done and any changes let me know.
Also any way I'm able to upvote or rate you on this website let me know because I owe you a virtual beer, think I'm slowly starting to learn.
Cheers

ID_CHECK    
Have the patron insert ID into the machine
        GET patron scanned photo
            GET eye colour FROM scanned photo
            (blue, green, brown, other)
            GET hair colour FROM scanned photo
            (black, blonde, brown, red, grey, other)
            GET skin tone FROM scanned photo
            (dark, medium, fair, other)
        READ ID number
        IF ID number is on file THEN
            authorize
        ELSE
            PRINT denied
        ENDIF
        READ patron name
        IF patron name is on file THEN
            authorize
        ELSE
            PRINT denied
        ENDIF

PATRON_CHECK
Have patron stand infront of camera
    GET patron photo
            GET eye colour FROM photo 
            (blue, green, brown, other)
IF 'photo' eye colour match 'scanned photo' THEN
                PRINT 'succeed'
                ELSE
                PRINT 'no-match'
                ENDIF
            GET hair colour FROM photo
            (black, blonde, brown, red, grey, other)
                IF 'photo' hair color match 'scanned photo' THEN
                PRINT 'succeed'
                ELSE
                PRINT 'no-match'
                ENDIF
            GET skin tone FROM photo
            (dark, medium, fair, other)
                IF 'photo' skin tone match 'scanned photo' THEN
                PRINT 'succeed'
                ELSE
                PRINT 'no-match'
                ENDIF
    IF no-match <1
        PRINT 'denied' 
    ELSE
        PRINT 'success'
    ENDIF
REPEAT ID_CHECK 
UNTILL all patrons have entered establishment
    PRINT establishment full
ELSE
    PRINT 'error'

The criterion was "if more than two features do not match they are denied". In that case

IF no-match <1
    PRINT 'denied'

should be

IF no-match > 2
    PRINT 'denied'

and you will want to keep track of the denials via a counter as in

IF not 'photo' skin tone match 'scanned photo' THEN
    increment no-match

Really appreciate you taking your time to help Reverend Jim thanks, hope everyone has a lovely week!

You'll notice I waited until all the heavy lifting was done ;-P

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.