$29
KEY ITEMS: Key items are marked in red. Failure to include or complete key items will incur additional deductions as noted beside the item.
Submission and Grading:
• All project deliverables are to be submitted in eLearning.
• Projects submitted after the due date are subject to the late penalties described in the syllabus.
• Each submitted program will be graded with a set of test cases. Each student is responsible for developing sample test cases to ensure the program works as expected.
• Type your name and netID in the comments at the top of all files submitted. (-5 points)
Objectives:
• Create multiple classes that interact with each other
• Implement a linked list with classes.
• Implement overloaded operators in a class
Problem: As usual, Wario is concerned about nothing other than acquiring more money. In order to maximize profits, Wario needs to use calculus to create derivatives for analysis. Unfortunately, Wario never took calculus; there wasn’t much need of it in the Mushroom Kingdom. So, Wario is calling on you to help him by creating a program to create derivatives.
Details
This project must use two classes
• Linked List class
• Node class
Linked List class
• Variables
o Head – node pointer
• Functions
o Default constructor
o Overloaded Constructor
Make copy of list passed in
o Destructor
o Delete the list
o Accessors and mutators
o Overloaded operators
Overloaded [ ]
• Return the node at the given index
Overloaded << operator
• Display the linked list
• Use [ ] notation to treat the linked list like an array
• See output format below
Overloaded ++ operator
• Prefix notation only
• Add node to head of linked list
Sort
• Sort the linked list in descending order by exponent
Node class
• Variables
o Outer coefficient o Inner coefficient o Exponent
o Trig identifier
o Node pointer
• Functions
o Default constructor
o Overloaded constructor
o Accessors and mutators
o Overloaded << operator
Display a single node (as a derivative)
See output format below
All nodes will be dynamically created
There should only be enough nodes to hold data for the current expression
You will have to consider a way to reuse the linked list for the next expression
All input will be read from a file
Each term in the expression will be stored into a node and added into the linked list
Each line in the file will be a mathematical function that can be derived
The number of lines in the file is unknown
Each calculated derivative will be written to a file
User Interface: There will be no user interface for this program
Input: All input will be read from a file named functions.txt. Each line in the file will be a mathematical function with the following parameters:
• Consist of polynomial terms - the highest degree will be 10
• May also contain trig functions
• Exponents will be represented by the ^ character.
• Exponents may be positive or negative
• Do not assume that the expression will be in order from highest to lowest exponent.
• All coefficients will be integers.
• The absence of a coefficient should be interpreted as a coefficient of 1
• Trigonometric functions may have coefficients
• The variable will always be ‘x’.
• There will be spaces around the operators between terms
• If a trig function is used, there will be a space between the trig function and the coefficient of x
• Example Input:
o 3x^2 + 2x + 1 o x^-2 + 3x + 4 o 4x – x^3
o 3sin x + cos x
o 1 – cos 4x
o 3x^4 – 6x^2 + tan 10x
Output: All output will be written to a file.
• The file will be named derive.txt.
• Each derivative will be written on a separate line.
• Use the ‘^’ character to represent exponents.
• The terms of the derivative must be ordered from highest to lowest exponent
• Trig functions should be listed at the end in the order they were encountered in the original expression
• The format of the output for each term will be the same as the input format
• Do not use double operators
• Invalid format: 2x^2 + -3x
Rules for Derivatives:
Function
Derivative
a
0
ax
a
axb
abx(b – 1)
c · f (x)
c · f '(x)
f (x) + g(x)
f '(x) + g'(x)
c · sin(ax)
a · c · cos(ax)
c · cos(ax)
–a · c · sin(ax)
c · tan(ax)
a · c · sec2(ax)
From: https://www.dr-aart.nl/Diff-and-int-rules-for-differentiation.html