Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this project for computer science!!! Can anyone help? following is the source code project1.cpp CSC 212 Project 1 Following is the

I need help with this project for computer science!!! Can anyone help? following is the source code project1.cpp
image text in transcribed
image text in transcribed
CSC 212 Project 1 Following is the source code proiectl soo. Given the Complex class and myStack implate class, complete the main function and then compile, debug and test your program C++ - project project.cpp Center> projectlnm k cemier Wheren is the size of the stack, mis the modular of the real part and imagination part of a random complexumber, and is the number of elements displayed per line. In the main function, you need to 1. 2. Get the values , m, and k from the command line Declare a complex number stack of size, generate random complex numbers and push them into the stack, meantime, display all these numbers, k numbers per line Display all elements of the stack, k elements per line 3. I/ Student Name I/ Student ID Il project.cpp #include Winclude #include using namespace std; class Complex float re: float im: complex number class real part imagination part publie: Complex (float -0.0,float -0.0)[re=r;im-i:) Complex const Complex&crec.re; imcim;) void operator (const Complex & crec.re; im c.im) Complex operator -(const return Complex-re, -im:) Complex operator+(const Complexe) const; Complex operator -(const Complexe) const; Complex operator (const Complex&) const; Complex operator (const Complex&) const: friend ostream& operator fostream&,const Complex & constructor I copy constructor assignment Nunary negation Waddition operator W subtraction operator multiplication operator W division operator output operator I addition operator Complex Complex operator+(const Complex& c) const float rrete.re; float l-imte.im; return Complex(r,i); / subtraction operator Complex Complex operator (const Complex& c) const { float rare-c.re: float i-im-c.im: return Complex(r.i): multiplication operator Complex Complex operator (const Complex& c) const float-rec .re-ime .m; float i-rec.im+ im c.re; return Complex(r.i); Complex Complescoperator (const Complex& c) const { Complex nm-Complex(*this) . Complex(c.re-c.im. Doar dn creere + c.im c.im II division operator float r-nm.re/ dn; float inm.im/dn; retum Complex(r.1); ostream& operator class myStack T ptr int size: int top: Il storage body I storage size I top position public: myStack(int); -myStackOffreeptr);} bool emptyOfreturn top -1:) bool full{return top-size-1: int getholdOfreturn top+1:} void push(Tv){ptr[+topl-v:} T popOfretum ptr top--1:} void display(int): W constructor destructor empty or not full or not I get number of items hold W put an item on top // take an item from top 1 pop and display, m items per line Il create an empty stack template myStackmyStack(ints) ptr-(T) malloc(s*sizeof(T)); sizes: top-1; Il pop and display, k items per line void myStackdisplay(int k) if(!emptyO) int h gethold: cout projectlnm k cemier Wheren is the size of the stack, mis the modular of the real part and imagination part of a random complexumber, and is the number of elements displayed per line. In the main function, you need to 1. 2. Get the values , m, and k from the command line Declare a complex number stack of size, generate random complex numbers and push them into the stack, meantime, display all these numbers, k numbers per line Display all elements of the stack, k elements per line 3. I/ Student Name I/ Student ID Il project.cpp #include Winclude #include using namespace std; class Complex float re: float im: complex number class real part imagination part publie: Complex (float -0.0,float -0.0)[re=r;im-i:) Complex const Complex&crec.re; imcim;) void operator (const Complex & crec.re; im c.im) Complex operator -(const return Complex-re, -im:) Complex operator+(const Complexe) const; Complex operator -(const Complexe) const; Complex operator (const Complex&) const; Complex operator (const Complex&) const: friend ostream& operator fostream&,const Complex & constructor I copy constructor assignment Nunary negation Waddition operator W subtraction operator multiplication operator W division operator output operator I addition operator Complex Complex operator+(const Complex& c) const float rrete.re; float l-imte.im; return Complex(r,i); / subtraction operator Complex Complex operator (const Complex& c) const { float rare-c.re: float i-im-c.im: return Complex(r.i): multiplication operator Complex Complex operator (const Complex& c) const float-rec .re-ime .m; float i-rec.im+ im c.re; return Complex(r.i); Complex Complescoperator (const Complex& c) const { Complex nm-Complex(*this) . Complex(c.re-c.im. Doar dn creere + c.im c.im II division operator float r-nm.re/ dn; float inm.im/dn; retum Complex(r.1); ostream& operator class myStack T ptr int size: int top: Il storage body I storage size I top position public: myStack(int); -myStackOffreeptr);} bool emptyOfreturn top -1:) bool full{return top-size-1: int getholdOfreturn top+1:} void push(Tv){ptr[+topl-v:} T popOfretum ptr top--1:} void display(int): W constructor destructor empty or not full or not I get number of items hold W put an item on top // take an item from top 1 pop and display, m items per line Il create an empty stack template myStackmyStack(ints) ptr-(T) malloc(s*sizeof(T)); sizes: top-1; Il pop and display, k items per line void myStackdisplay(int k) if(!emptyO) int h gethold: cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago