Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to simulate a coin flip
- local function coinFlip()
- local randomNumber = math.random(1, 2) -- Generate a random number (1 for heads, 2 for tails)
- if randomNumber == 1 then
- return "Heads"
- else
- return "Tails"
- end
- end
- -- Main program
- function main()
- print("Welcome to the Coin Flip Simulator!")
- while true do
- print("\nPress any key to flip the coin, or type 'exit' to quit.")
- local input = read() -- Read user input
- if input:lower() == "exit" then
- print("Exiting the program...")
- break -- Exit the loop
- else
- local result = coinFlip()
- print("You got: " .. result)
- end
- end
- print("Thank you for using the Coin Flip Simulator!")
- end
- -- Start the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement