| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Exercise - Conditional Loops - Q4b

Page history last edited by Steve Sweeney 11 years, 5 months ago

/* Create a program that checks user name and password. */

var username, password : string

var validLogin : boolean

validLogin := false

loop

    put "User Name: " ..

    get username

    put "Password: " ..

    get password

    put ""              % add an extra line for nice output

    if (username = "bob") and (password = "robert") then

        validLogin := true

    elsif (username = "bill") and (password = "william") then

        validLogin := true

    elsif (username = "tim") and (password = "timothy") then

        validLogin := true

    end if

    exit when (validLogin = true)

end loop

put "Access granted"

 

Comments (0)

You don't have permission to comment on this page.