CISP 1010, Lab 3, Arrays and C-Strings Introduction This application creates Mad Lib™M haikus based upon user input. Detailed Information The application reads three-line haikus into a two-dimensional array of characters (an array of C-strings, not C++ string objects) from an input file called haikus.dat. Do not ask the user for this file name. Just open it and read its contents into a two-dimensional array. A sample input file with two haikus is shown below. Flowers sit in Shades of the * tree near * in sunset When begins the * And the * Crocus blooms * any thing The asterisk will actually be in the file. They indicate where words that the user enters go in the haiku. The asterisk on the first line will be replaces by a one syllable noun and on the second line will be replaced by a two syllable adjective. These two askterisks will never be the first character of the line. The asterisk on the third line will always be the first character on the line and will be replaced by a gerund (a verb ending in “ing" such as "asking") whose first character the program will have to capitalize. The two dimensional array of characters for the sample input file is shown below. F10wers Sit| Shade 55 0f| i n 5unset \0 When begins And the Cr 0cuS | a n|y| |thing\0 Assume that no one line of a haiku will be longer than 50 characters and have space in the array for no more than 30 haikus from the input file haikus.dat. Since the input file might have more or less than 30 haikus, the program code must handle these situations by reading until the end of the file but not reading more than 30 in \0 he t t ee ne a the |b10 0 m5 \0| hailne Thoe will hn no nartial haikue in the innut file haikus. There will be no partial haikus in the input file. After the program reads the file contents into the two-D array, it should ask the user for a one syllable noun, a two syllable adjective and a two syllable gerund. The program then randomly selects a haiku, substitutes the one syllable noun for the first * in the haiku, the two syllable adjective for the second, and the gerund for the third, and prints this new haiku. The program continues asking for words until the user doesn't type Y (or y) to continue. Error checking is described below. • If the input file, haikus.dat, does not exist, print the following error message and end the program. Haiku file non-existent. Please contact the administrator.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
CISP 1010, Lab 3, Arrays and C-Strings
Introduction
This application creates Mad Lib™ haikus based upon user input.
Detailed Information
The application reads three-line haikus into a two-dimensional array of characters (an array of C-strings,
not C++ string objects) from an input file called haikus.dat. Do not ask the user for this file name. Just open it
and read its contents into a two-dimensional array. A sample input file with two haikus is shown below.
Flowers sit in *
Shades of the * tree near
* in sunset
When begins the *
And the * Crocus blooms
* any thing
The asterisk will actually be in the file. They indicate where words that the user enters go in the haiku.
The asterisk on the first line will be replaces by a one syllable noun and on the second line will be replaced by a
two syllable adjective. These two askterisks will never be the first character of the line. The asterisk on the third
line will always be the first character on the line and will be replaced by a gerund (a verb ending in “ing" such
as "asking") whose first character the program will have to capitalize. The two dimensional array of characters
for the sample input file is shown below.
F10werS
Shade 5 S 0 f|
|in|
When
And the *
a ny| |t|hing\0
|sit[
in*\0
he
t
r \0
*
t
ree
e
a
Sunset \0
begin s
*
|t]he
Cr 0cu s
b 10 0 m s \0
*
Assume that no one line of a haiku will be longer than 50 characters and have space in the array for no
more than 30 haikus from the input file haikus.dat. Since the input file might have more or less than 30 haikus,
the program code must handle these situations by reading until the end of the file but not reading more than 30
hailne Thee will ha no nartial haikue in the innut file
haikus. There will be no partial haikus in the input file.
After the program reads the file contents into the two-D array, it should ask the user for a one syllable
noun, a two syllable adjective and a two syllable gerund. The program then randomly selects a haiku, substitutes
the one syllable noun for the first * in the haiku, the two syllable adjective for the second, and the gerund for the
third, and prints this new haiku. The program continues asking for words until the user doesn't type Y (or y) to
continue.
Error checking is described below.
• If the input file, haikus.dat, does not exist, print the following error message and end the program.
Haiku file non-existent. Please contact the administrator.
Transcribed Image Text:CISP 1010, Lab 3, Arrays and C-Strings Introduction This application creates Mad Lib™ haikus based upon user input. Detailed Information The application reads three-line haikus into a two-dimensional array of characters (an array of C-strings, not C++ string objects) from an input file called haikus.dat. Do not ask the user for this file name. Just open it and read its contents into a two-dimensional array. A sample input file with two haikus is shown below. Flowers sit in * Shades of the * tree near * in sunset When begins the * And the * Crocus blooms * any thing The asterisk will actually be in the file. They indicate where words that the user enters go in the haiku. The asterisk on the first line will be replaces by a one syllable noun and on the second line will be replaced by a two syllable adjective. These two askterisks will never be the first character of the line. The asterisk on the third line will always be the first character on the line and will be replaced by a gerund (a verb ending in “ing" such as "asking") whose first character the program will have to capitalize. The two dimensional array of characters for the sample input file is shown below. F10werS Shade 5 S 0 f| |in| When And the * a ny| |t|hing\0 |sit[ in*\0 he t r \0 * t ree e a Sunset \0 begin s * |t]he Cr 0cu s b 10 0 m s \0 * Assume that no one line of a haiku will be longer than 50 characters and have space in the array for no more than 30 haikus from the input file haikus.dat. Since the input file might have more or less than 30 haikus, the program code must handle these situations by reading until the end of the file but not reading more than 30 hailne Thee will ha no nartial haikue in the innut file haikus. There will be no partial haikus in the input file. After the program reads the file contents into the two-D array, it should ask the user for a one syllable noun, a two syllable adjective and a two syllable gerund. The program then randomly selects a haiku, substitutes the one syllable noun for the first * in the haiku, the two syllable adjective for the second, and the gerund for the third, and prints this new haiku. The program continues asking for words until the user doesn't type Y (or y) to continue. Error checking is described below. • If the input file, haikus.dat, does not exist, print the following error message and end the program. Haiku file non-existent. Please contact the administrator.
continue.
Error checking is described below.
• If the input file, haikus.dat, does not exist, print the following error message and end the program.
Haiku file non-existent. Please contact the administrator.
• If the input file, haikus.dat, is empty, print the following error message and end the program.
Haiku file is empty. Please contact the administrator.
This lab requires the use of C-string, not CH string objects. Write and use at least two functions besides
main. Use constants where appropriate.
Sample execution
Welcome to Mad Lib Haikus!
Enter a one syllable noun: car
Enter a two syllable adjective: yellow
Enter a two syllable gerund (a verb ending in "ing" like "asking"):
trying
Your Mad Lib Haiku:
When begins the car
And the yellow Crocus blooms
Trying any thing
Continue (Y/N) ? y
Enter a one syllable noun: ear
Enter a two syllable adjective: fluffy
Enter a two syllable gerund (a verb ending in "ing" like "asking"):
walking
Your Mad Lib Haiku:
Flowers sit in ear
Shades of the fluffy tree near
Walking in sunset
Continue (Y/N)? N
Thank you for using Mad Lib Haikus!
Transcribed Image Text:continue. Error checking is described below. • If the input file, haikus.dat, does not exist, print the following error message and end the program. Haiku file non-existent. Please contact the administrator. • If the input file, haikus.dat, is empty, print the following error message and end the program. Haiku file is empty. Please contact the administrator. This lab requires the use of C-string, not CH string objects. Write and use at least two functions besides main. Use constants where appropriate. Sample execution Welcome to Mad Lib Haikus! Enter a one syllable noun: car Enter a two syllable adjective: yellow Enter a two syllable gerund (a verb ending in "ing" like "asking"): trying Your Mad Lib Haiku: When begins the car And the yellow Crocus blooms Trying any thing Continue (Y/N) ? y Enter a one syllable noun: ear Enter a two syllable adjective: fluffy Enter a two syllable gerund (a verb ending in "ing" like "asking"): walking Your Mad Lib Haiku: Flowers sit in ear Shades of the fluffy tree near Walking in sunset Continue (Y/N)? N Thank you for using Mad Lib Haikus!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education