Question
The program will read a person's diary (or perhaps several files) and store the data in vectors in the program. There are two types of
The program will read a person's diary (or perhaps several files) and store the data in vectors in the program. There are two types of information that appear in the file. Food lines have the format o the word "food" o thenameofthefood o the date the food was eaten on o example:foodbanana2018/10/26 There are also "feel" lines in the file, with the following format o the word "feel" o thenameofthefeeling o thedatethisfeelingoccurred o example: feel headache 2010/10/26 The program will go through the data and calculate, for each food, what fraction of the time (when you eat it) that it gives you the various feelings. The program will report any food-to-feeling connections that happen at least half the time. Recommended Program Parts Define Day struct You will need to have a Day struct that has -- a date (string, eg "2020/3/4", there's no real need to unpack it as 3 numbers), -- a vector of strings for the foods eaten that day, and -- a vector of strings for the feelings of that day.
The main() function should have -- a vector of strings which are foods (all foods that appear in the file, 'master' list),
-- a vector of strings which are feelings (all feelings, the master list), and -- a vector of pointers to Day structs. These have to be pointers.
-- a loop allowing the user to read a file, analyze the data, clear the data, or quit. These options should call a function to do it, so that main() is pretty short.
readDiary( 3 parameters are references or pointers to the 3 vectors in main)
-- This function should ask the user for the filename of the file to read. Then it reads and parses the file, and loads the data into the various vectors. If there is already some data in the vectors, this should add to it. Do not erase existing data.
-- For "food" lines, add the food to the master list of foods (if it is not already there) and also to the food list in the Day struct for this date.
-- For "feeling" lines, add the feeling to the master list (if not already there) and also to the Day for this date.
-- For the parameters, make sure to use references or pointers, so that the function has access to the originals, not copies.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started