Starting from:
$29.99

$26.99

Assignment #3 functions and arguments in C++

CS162  Program #3
Programming Assignment #3
CS 162: Introduction to Computer Science
Submit your assignment to the D2L Dropbox
Submit your assignment only once and to the correct dropbox!
Upload your external data file as well.
*** Your algorithm should be written in paragraph form for Program #3 ***
Programming. The purpose of the third program is to continue refining our use
of functions and arguments in C++ and practice using arrays of characters,
arrays of structures, and external data files. This is directly related to what was
is covered with Lab #5. Again, our goal is to create programs with a small
functions where main delegates to a series of functions where the real work takes
place. In this programming assignment, you are not allowed to use global
variables. Limit your functions to no more than 30 statements of code (for
executable statements… not counting variable definitions, blank lines, lines with just
curly brackets, or comments).
Program Assignment:
Looks like this summer we may be having “stay-cations” or vacations that are
staying around home. Maybe they are at home! Maybe they involve day trips
around town. I saw a news clip where one family is having themed dinners –
dressing up for different occasions (like “going” to the beach although we are
really still here). Think of all of the cool things we could do? We could put
posters of the beach, bring in sand and sea shells (ok, maybe in a sand-box), and
much more. Or, if you are thinking outside the box, what about themed zoom
meetings, where there are beach “outings”, tasting events, and all sort of stay at
home (but away) activities. We could experience themed cooking classes with
our favorite chefs?!
Your job for program #3 is build a program to help keep track of the best ideas
for stay and home vacations:
a. Name of the stay-cation activity
b. Description of what it would be like
c. A list of materials needed (no more than 5)
d. Hands on requirements (e.g., we are cooking at the same time, need
to be logged into zoom, etc.)
It is expected that you will create a structure to hold the aforementioned items
and store all of the information in memory using an array of structures. Make
sure your array size is small enough to test but large enough to make sense.
CS162 Spring 2020 Program #3
A large part of this assignment is the use of structs and arrays of structs.
Therefore, your program will need to READ the information from the user,
and store it in an array of structs. Then, once it has been read in allow the user
to display all possible stay at home activities (in the order read in).
An extra function we want you to support is the ability to search the array for a
particular activity (by its name) and display all of the information about that
particular stay-cation. This is important!
External Data Files: Another large piece of this assignment is to use external data
files, so that the information isn’t lost at the end of the program. With external
data files, the information that you store in the files must be written in such a
way that it is easy to read it back in. Your file should have ‘|’ between each of
the above fields. Name it staycation.txt
You will want to build a small menu for this program.. Give them a choice of at
least the following (Perform the above over and over until the user wants to quit):
1. Load from a file
a. Read in an existing favorite staycation activities and store it into
your array of structures
2. Add a new item to the list
a. Read in information from the user for something to add to the list.
b. Append this information to the external data file
3. Search for a matching activity by its name to display all of the information
about that activity
4. Display all
5. Quit
Make sure to keep all files (.cpp and .txt) in your “current working directory” on
linux as the grader will not be able to replicate your directory structure. And,
include the data file when submitting your work into D2L.
***You are always welcome to do more! Really focus on making general purpose
functions that can be re-used. And, get more practice with arrays of characters!
Things you should know...as part of your program:
1. Make sure to prompt the user for any input requested. Make sure it is
clear from your prompts what the user is expected to do.
2. You may not use any global variables in this program!
3. You may not use the string class – instead use arrays of characters. You
are allowed to use the cstring library.
CS162 Spring 2020 Program #3
4. Make sure to use C++’s I/O (iostream library) for your input and output.
5. After each input operation, make sure to use cin.ignore to remove the
delimiters!
6. With external data files, first read before checking for end of file:
i. Read the first item
ii. While (!infile.eof())
1. Process what was read
2. Read again (prime the pump!)

More products