[Solved] CmpE 250- Data Structures and AlgorithmsAssignment 1

$25

File Name: CmpE_250-_Data_Structures_and_AlgorithmsAssignment_1.zip
File Size: 489.84 KB

SKU: [Solved] CmpE 250- Data Structures and AlgorithmsAssignment 1 Category: Tag:
5/5 - (1 vote)

1 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 file. Your program should read the input file and store the valuable information in the records in a LinkedList. As a final 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 files you will be given are:

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

The files 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!

2 Details of the Given Code

2.1 Node

This class consists of two data fields 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 instances 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:

  • 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 minimum 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 maximum 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 files.

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 file.

3 Input/Output Format

3.1 Input Format

The first line of the input file 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 fields: 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 first 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 file.

  • Min : The minimum amount of expenses.
  • Max : The maximum amount of expenses.
  • Avg : The average amount of expenses.

4 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

5 Grading

  1. Your program will be compiled with cmake CMakeLists.txt && make
  2. Only the changes in LinkedList.cpp and SurveyClass.cpp files will begraded. Therefore, implement all your code in these two files.
  3. I will execute your program with ./project1 inputFile outputFile
  4. Grading of this project is based on the success of your code in testcases. Your score will be the sum of collected points from each test case. Each test case will have equal weight. Maximum score is 100.

6 Warnings

  1. You are not allowed to use any library or object provided by C++ foranalyzing a LinkedList. You will get zero in this case.
  2. You are expected to implement destructor, copy constructor, overloadcopy assignment operator, move constructor and overload move assignment operator. Otherwise, when extensively tested, your code will very likely give segmentation fault and crash even though the statistical operations are just fine.
  3. Make sure an executable is created after executing cmake CMakeLists.txt && make Otherwise, no executable will be created and your code will fail in grading.

7 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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CmpE 250- Data Structures and AlgorithmsAssignment 1
$25