[Solved] CMPE250 Project1-Statistics on the expense records

$25

File Name: CMPE250_Project1-Statistics_on_the_expense_records.zip
File Size: 471 KB

SKU: [Solved] CMPE250 Project1-Statistics on the expense records Category: Tag:
5/5 - (1 vote)

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

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] CMPE250 Project1-Statistics on the expense records
$25