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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Exercise - Conditional Loops - Q4b

Page history last edited by Steve Sweeney 15 years, 1 month 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.