- This event has passed.
4 PM – Intro To Java – Gamas
November 5, 2022 @ 4:00 pm - 5:00 pm
Homework
- In Nov5Magic8Ball.java, use combination of Random module, while loop, if else statements to create Magic 8 Ball game.
- Look at below Python codes for your reference
-
import random while True: user_question = input("\nEnter your question? ") if user_question.lower() == "quit" or user_question.lower() == "exit": print("Bye bye") break random_num = random.randint(1,8) if random_num == 1: print("It is certain") elif random_num == 2: print("Most likely.") elif random_num == 3: print("Signs point to yes.") elif random_num == 4: print("I don’t think so.") elif random_num == 5: print("Ask again later.") elif random_num == 6: print("Concentrate and ask again.") elif random_num == 7: print("Outlook not so good.") elif random_num == 8: print("My reply is no")