Starting from:

$35

CPE2600 Lab 7 -Vector Calculator Updates Solution

Lab 7 Vector Calculator Updates
Introduction
The purpose of this assignment is to update our vector calculator program with additional features.
Work on the assignment is to be done individually. You are welcome to collaborate with class members, but the project must be your own work. Project Description
This project will add two features to your vector calculator program - the ability to load and save vectors to and from files, and the ability to store “unlimited” vectors through the use of dynamic memory.
Dynamic Memory
In any case, adding this feature should not change the outward appearance of your program at all. Instead of having the limit of 10 vectors, your program should happily continue to store vectors until heap memory is exhausted.
An example CSV file content:
a,1,2,3 b,4.4,5.5,6.6 c,8.8,11,13.2 d,17.6,22,26.4
Implementation Requirements
o Your implementation must release dynamic memory when the clear command is issued. This makes sense for linked-list implementations. It might not make sense for dynamic array implementations, but it is a requirement nonetheless.
o Your implementation must release all memory when exiting. While not absolutely required, consider using atexit() to register an exit handler and/or a signal handler for SIGINT to trap CTRL-C and exit gracefully. Your demo will require running with valgrind to prove no memory leaks at exit.
2. File I/O o Add a command to load a CSV file. the command will simply be load <fname> where <fname> is the file to be loaded. It should be noted that <fname> cannot contain spaces, but relative and absolute paths should work
(i.e. ../data1.csv or /home/user/data/f1.csv or myData.txt). Do not add .csv to the entered filename programatically, and do not necessarily expect the filename entered by the user to have a .csv extension.
▪ You must gracefully handle a missing (or mistyped) file.
▪ You must gracefully handle a mis-formatted CSV file.
▪ Should you clear vector storage before loading a file or merge the contents of the file with vectors already in memory, possibly overwriting some vectors? This is completely up to you in your design.
o Add a command to save all current vectors in memory to a CSV file. The file should only include actual vectors (no empty or null vectors). This file should be formatted such that it can be read in via the load command as well as opened by Excel. It does not make sense to append to an existing file, so it should overwrite a file should it already exists. The command should simply be save <fname> and the same behavior for relative and absolute paths apply as noted above.
3. OPTIONAL - It might be nice to exercise your dynamic memory capabilities. Add a fill function to automatically generate a large number of vectors.
Deliverables
For submission, you will push the updated code to the git repository along with a tag marking the “release” of new features. You will also provide a README.md file with an overview of the project. Details and instructions for the tagging and README.md file will be provided during lab in Week 8 and will be part of the Week 8 in-lab activities.
The general demo script will be:
• make clean
• make // project builds with no warnings
• run program via valgrind
• attempt to load non-existing csv file // program reports non-existing file
• load provided csv file // observe loaded vectors
• load provided csv file again // observe same set of vectors
• do an operation resulting in a new vector
• save to new csv file
• exit program // observe valgrind not report errors or leaks
• run program
• load file saved // observe all vectors present
• observe saved file in editor or Excel

More products