Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

=+7. Are shareholders in a firm investors or gamblers?

Answered: 1 week ago