Starting from:
$30

$24

Assignment 1 Solution




Description



You are going to be implementing a C++ program for generating the statistics on the expense records of a group of people. The expense records will be provided in the input le. Your program should read the input le and store the valuable information in the records in a LinkedList. As a nal step, your program will calculate the expected statistics over the LinkedList.




You will be provided some initial code and you are going to implement the missing part.




The les you will be given are:




Node.h, Node.cpp, LinkedList.h, LinkedList.cpp, SurveyClass.h, SurveyClass.cpp and main.cpp




The les you should write your code in are:




LinkedList.cpp, SurveyClass.cpp




In other words, you are expected to implement the methods, constructors and destructors, which are prototyped in LinkedList.h and SurveyClass.h.




Important Note: For this project, any code written outside LinkedList.cpp and SurveyClass.cpp will be meaningless for grading!
















































Details of the Given Code



2.1 Node




This class consists of two data elds for storing the data and a Node pointer to the next node which will be used to construct LinkedList. The copy constructor and destructor and some operator overloading are implemented for you.




2.2 LinkedList




This is the class you will be implementing and consists of two Node in-stances that represent the head and the tail of the list and an integer to keep the length of the list. LinkedList.h is already written for you and you are responsible for implementing LinkedList.cpp. To implement the project successfully, you are going to:




implement a pushTail function : Adds a new node to the end of the list




implement an updateNode function : Updates the amount of money in a given node




implement constructor




implement copy constructor




overload copy assignment operator implement move constructor




overload move assignment operator implement destructor




2.3 SurveyClass




This is the class you will be implementing and contains a pointer to a LinkedList object, which will be used to represent the group of people read. SurveyClass.h is already written for you and you are responsible for implementing SurveyClass.cpp. To implement the project successfully, you are going to:













2















implement handleNewRecord function : Adds a new Node object to the linked list or updates a corresponding Node




implement the minimum function : Calculates and returns the mini-mum amount of money for the input expense records. The minimum amount can have up to two decimal points.




implement the maximum function : Calculates and returns the maxi-mum amount of money for the input expense records. The maximum amount can have up to two decimal points.




implement the average function : Calculates and returns the average amount of money for the input expense records. The average amount can have up to two decimal points.




implement constructor




implement copy constructor




overload copy assignment operator implement move constructor




overload move assignment operator implement destructor




You can of course implement additional helper functions but make sure that you do not modify other les.




2.4 main.cpp




This is the class where you will be handling the input and output. Most of the I/O coding has already been implemented. You are allowed to modify this class for your implementation tests. But remember that we will replace yours with the original for grading tests. Note that when you execute the main after removing /* and */ signs, your output must be the same as the corresponding result le.































3















Input/Output Format



3.1 Input Format




The rst line of the input le holds an integer, N, showing the number of data lines.




In the following N lines, the expense records are given, one per line. Each record is a sentence which starts with the name of the group member and contains the amount of money starting with symbol ’$’. Note that the amounts can have decimal values.




The assignment is to read in each expense record and tokenize it for two elds: the name of the group member and the amount of money. The tokens will be stored in a Node in the LinkedList. If it is the rst expense record of the member, create a new Node. If the name was already in the linked list, update the amount with the new one.




3.2 Output Format




Your program should calculate and print out the three statistics in one single line separated with a single space in the output le.




Min : The minimum amount of expenses.




Max : The maximum amount of expenses.




Avg : The average amount of expenses.







Examples



For the input data:




5




Ali bought a pencil with $5




Ayse spent $80 for clothing




Mine ordered a course book for $100




Ahmet spent $100 for his new bag




Ali bought a notebook with $20




The correct result is:




20 100 75













4















Grading



Your program will be compiled with cmake CMakeLists.txt && make command.



Only the changes in LinkedList.cpp and SurveyClass.cpp les will be graded. Therefore, implement all your code in these two les.



I will execute your program with ./project1 inputFile outputFile command.



Grading of this project is based on the success of your code in test cases. Your score will be the sum of collected points from each test case. Each test case will have equal weight. Maximum score is 100.






Warnings



You are not allowed to use any library or object provided by C++ for analyzing a LinkedList. You will get zero in this case.



You are expected to implement destructor, copy constructor, overload copy assignment operator, move constructor and overload move assign-ment operator. Otherwise, when extensively tested, your code will very likely give segmentation fault and crash even though the statistical op-erations are just ne.



Make sure an executable is created after executing cmake CMake-Lists.txt && make commands. Otherwise, no executable will be created and your code will fail in grading.






Submission Details



You are supposed to use the Github Classroom system provided to you for all projects. No other type of submission will be accepted.





































5

More products