Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

getFilename(fileName) OPEN fin from fileName IF error in fin DISPLAY error RETURN 0 WHILE numWords askQuestions(story[numWords]) numWords++ CLOSE fin RETURN numWords END Pseudocode for askQuestions()

image text in transcribed

getFilename(fileName)

OPEN fin from fileName

IF error in fin

DISPLAY error

RETURN 0

WHILE numWords

askQuestions(story[numWords])

numWords++

CLOSE fin

RETURN numWords

END

Pseudocode for askQuestions()

askQuestions(text)

IF text[0]

return

PUT tab and toupper(text[1])

FOR iText = 2 until text[iText] = >

IF text[iText] = _

PUT space

ELSE

PUT tolower(text[iText])

PUT colon and space

GET text

END

Using the structure chart above and the Pseudocode

with c++

write the code necessary read the Mad Lib from a file and prompt the user:

Please enter the filename of the Mad Lib: madlibZoo.txt Plural noun: boys Plural noun: girls Type of liquid: lemonade Adjective: fuzzy Funny noise: squeak Another funny noise: snort Adjective: hungry Animal: mouse Another animal: blue-fin tuna 

Note that there is a tab before each of the questions (ex: "Plural noun:")

Hints

Your program will not need to be able to handle files of unlimited length. The file should have the following properties (though you will need to do error-checking to make sure):

There are no more than 1024 characters total in the input file.

There are no more than 32 lines in the input file.

Each line in the input file has no more than 80 characters in it.

There are no more than 256 words in the input file including prompts.

Each word in the input file is no more than 32 characters in length.

Hint: To see how to declare and pass an array of strings, please see Chapter 3.0 of the text.

Assignment

Perhaps the easiest way to do this is in a four-step process:

Create the framework for the program using stub functions based on the structure chart from your design document.

Write each function. Test them individually before "hooking them up" to the rest of the program. You are not allowed to use the String Class for this problem; only c-strings!

Structure chart: main stor story, le continue ngth readFile playAgain displayStory fileName character isPunc getFilename askQuestions isPunc

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions