Lab 3: Fortune Teller

You will be designing your own fortune teller for this lab.

The file fortune.txt contains some fortunes proverbs that you will use for this lab.

The first line of the file contains the number of fortunes proverbs in the file.

You have been given code to open a file and read the contents of the file.

Stage 1: Random Fortune (1 Point)

In the function displaySingleRandomFortune

  write your code to display a random fortune from the list

    HINT : Select a random number between 0 and number of lines of fortune proverbs

    Display the fortune at that line number.

   

    Running the program will look like:

            Lab 3: Fortune Teller

            Select from the following:

                 1. Get random fortune

                 2. Get all fortunes starting with letter

                 3. Get the fortune from a fortunate line number

                 4. Exit the program

              Your choice --> 1

              Fortune for today: Have a beautiful day.

           

   

Stage 2: Fortune by Fortune letter (1 Point)

In the function displayAllAfterLetter

    Write your code to display all fortune proverbs following the line that start with a specific letter

        1) When you select the option 2, the program asks you to enter an alphabet.

        2) Use this alphabet to find the line that starts with that letter and display all fortune proverbs including that one.

        3) If there are no fortune proverbs with that letter it should display

           Sorry fortune not available.

   

          Running the program will look like:

  

            Lab 3: Fortune Teller

            Select from the following:

               1. Get random fortune

               2. Get all fortunes starting with letter

               3. Get the fortune from a fortunate line number

               4. Exit the program

            Your choice --> 2

            Enter the fortune letter:Y

            You always bring others happiness.

            You are a person of another time.

            You are a talented storyteller.

            You are admired by everyone for your talent and ability.

       

Stage 3: Extra Credit ( 1 Point)

In the function displayFortuneAt

  write your code to display a fortune at the specified line number

        1) When you select option 3, the program asks you to enter a line number.

        2) Use this line number to display the fortune at that line number.

        3) If the line number is greater than number of lines in the file

        display "Invalid fortune number..."

   

    Running the program will look like:

   

            Lab 3: Fortune Teller

            Select from the following:

               1. Get random fortune

               2. Get all fortunes starting with letter

               3. Get the fortune from a fortunate line number

               4. Exit the program

            Your choice --> 3

            Enter the fortune number:67

            Fortune for today: Do not underestimate yourself. Human beings have unlimited potentials.