Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function called get_fortune that takes an integer and returns a string representing the fortune associated with that integer. You should have at least
Write a function called get_fortune that takes an integer and returns a string representing the fortune associated with that integer. You should have at least 5 fortunes in your fortune teller. In your main program, prompt the user for a number between 0 and 5 (or more if you choose), then pass that number to get_fortune. Print the return value string that comes back from get_fortune. Be sure you print back in main, not in get_fortune. Example output could be: Please enter a number between 1 and 5 to hear your fortune: 3 Your fortune is.... It is your lucky day! Add comments to your program starting with your name at the top, then throughout your program to describe what you are doing. Be sure and make your calculations clear, giving your variables meaningful names. Also be sure to indent consistently throughout your program to make it more readable. Be sure you run this and test it a few times before submitting. Extra Credit: For 5 points of extra credit, do not let the user enter a number greater than 5 (or your max) or less than 0. Do some error checking in your main program to make sure their input is valid, otherwise give them an error message and exit the program. For example: Please enter a number between 1 and 5 to hear your fortune: 6 Invalid input, please make sure your number is between 1 and 5. Goodbye
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started