- Read in a file of complex numbers (126import.txt) and store them in an array o
ID: 3799864 • Letter: #
Question
- Read in a file of complex numbers (126import.txt) and store them in an array of complex objects. (Please include complex.h, complex.cpp and main.cpp)
- Create a menu to allow console add / delete / list and save functions.
Add: Allows user to append a new complex number into an array of complex numbers
Delete: Removes one complex number from an array of complex numbers either by selecting an index or by searching for a specific complex number
List: Prints out an array of complex numbers in ascending order according to magnitude onto the console
Save: Saves the array of complex numbers into a file
The magnitude of a complex number a+bi is sqrt(a*a+b*b).
Save function stores the results to file 126complex.txt
--------------------------------------------------------------------------------------
File: 126import.txt
1+1i
3.3+3.4i
4.4-4.5i
-5.5-5.6i
-6
7i
-8i
2+i
Explanation / Answer
#include #include #include using namespace std; /* * Node Declaration */ struct node { int info; struct node *next; struct node *prev; }*start, *last; int counter = 0; /* * Class Declaration */ class double_clist { public: node *create_node(int); void insert_begin(); void insert_last(); void insert_pos(); void delete_pos(); void search(); void update(); void display(); void reverse(); void sort(); double_clist() { start = NULL; last = NULL; } }; /* * Main: Contains Menu */ int main() { int choice; double_clist cdl; while (1) { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.