Activity 3.1

Source Code

-- define main function
function main()
    print("Hello Main Function")
    local choice = nil
    print("Menu")
    print("E1 - Example 1")
    print("Q - Quit")
    io.write("Choice: ")
    choice = io.read()
    if choice == "E1" then
        -- Example 1 Function call
        example1()

    elseif choice == "Q" then
        done = true
    else
        print("Invalid Choice")
    end
end

-- define Example 1 Function
function example1()
    print("Example 1")
    -- define friends list
    

    -- print the number of elements
   

    -- print the element one by one
    

    -- using a for loop, print the index and elements
    

    -- assign value to first friend
    

    -- assign value to the last friend
    

    -- print the friends
    

end

-- call to main function, do not delete!
main()

a31problem1.lua

a31problem2.lua

a31problem3.lua

a31problem4.lua

a31problem5.lua

Last updated

Was this helpful?