A polynomial may be represented as a linked list where each node contains the coefficient term of the polynomial. The polynomial 4 X¹-3 X- -5 would be represented as a linked list given below. Equation! KEYWORDS: Classes Pointers Submit 3 Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. 2 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being: summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted) Equation: Equation2: Result: -5 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions All methods used in the program MUST be written in C++ and included in the program. B) Equation1: Equation2: Result: C) Equation1: Equation2: Result: 0 3₂ a. Documented program b. Input file. < Must contain the sample equations given below> c. Output file. d. All items stapled. Test run for the following inputs (Do not change the order of exponent in the input file) A) 18X-7X+6X² +6 8X³-7X+6X² +6 8X³-7X²+6X+9X³-8 X³ +6X+17X³-X² -2 8X-7X+6X¹+9X²-8X+9 26X-7X-X'+15X² -8X+15 8X-6+5X² +6X²+8X³-7X² +6X 9X³-6X²+5X + 18X²-9 8X-7X+14X³ +5X +26X³ +6X-15

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Please write a SIMPLE C++ Code that takes the equation numbers of A,B and C from the input file, adds the 2 polynomials equations adjacent to each other together and then print out the results to an output file. Please include all files that should be in the code to your response. also make sure that the code is runnable. The prompt with all other directions is down below. A mini sample code is also there if you need any help
struct nodetype
int coeff;
int exp;
nodetype *next;
};
class equation
(
private:
};
public:
nodetype *begin, "last;
int length;
//Default constructor
equation();
// Method to insert an item in the linked list in a sorted order
void insertitem( nodetype temp);
// Method to output all the items in the linked list
void printlist();
// Method to add two equaition
equation add(equation e2);
Transcribed Image Text:struct nodetype int coeff; int exp; nodetype *next; }; class equation ( private: }; public: nodetype *begin, "last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2);
A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a
term of the polynomial. The polynomial 4 X-3X¹-5 would be represented as a linked list given below.
Equation!
4
3
Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores
them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result
as a polynomial to an output file. The result should be a third linked list.
KEYWORDS: Classes
Pointers
Submit
Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being
summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the
sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted).
2
NOTE: Must write a very general program using Object oriented concept. Do not use any library functions.
All methods used in the program MUST be written in C++ and included in the program.
40
0
131
Equation:
Equation2:
Result:
a. Documented program
b. Input file. <Must contain the sample equations given below>
c. Output file.
d. All items stapled.
B) Equation1:
Equation2:
Result:
Test run for the following inputs (Do not change the order of exponent in the input file)
A)
18X-7X³ +6X² +6
8X'-7X+6X¹+9X²-8X+9
26X5-7X¹ X³ + 15X²-8X+15
C) Equation1:
Equation2:
Result:
8X³-7X²+6X² +6
8X³-7X+6X +9X³-8
X³ +6X¹ +17X³-X² -2
8X³-6+5X² +6X²+8X³-7X² +6X
9X-6X²+5X¹ +18X²-9
8X-7X+14X +5X +26X³ +6X-15
Transcribed Image Text:A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a term of the polynomial. The polynomial 4 X-3X¹-5 would be represented as a linked list given below. Equation! 4 3 Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. KEYWORDS: Classes Pointers Submit Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. 40 0 131 Equation: Equation2: Result: a. Documented program b. Input file. <Must contain the sample equations given below> c. Output file. d. All items stapled. B) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) A) 18X-7X³ +6X² +6 8X'-7X+6X¹+9X²-8X+9 26X5-7X¹ X³ + 15X²-8X+15 C) Equation1: Equation2: Result: 8X³-7X²+6X² +6 8X³-7X+6X +9X³-8 X³ +6X¹ +17X³-X² -2 8X³-6+5X² +6X²+8X³-7X² +6X 9X-6X²+5X¹ +18X²-9 8X-7X+14X +5X +26X³ +6X-15
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education