Please write your original code in c++ Thank you Objective Create a class named Complex to represent complex numbers. Use the main() function and create at least three complex number objects and test all member functions of the Complex class. How to use classes. Related SLO Develop properly structured multifile programs with automatic compilation. Use classes in C++. Instructions Create a program named LastnameFirstname18.cpp, that does the following: Note: This program has no user input. Define a class called Complex that will represent a complex number. Complex numbers have the form a + bi, where a is the real part and b is the imaginary part. Both the a and b coefficients are real numbers. i is the square root of negative one, but it's not actually implemented in code. For this assignment, you will only be working with a and b. Wikipedia page for Complex numbers: here Declare 2 private double data members: real and imaginary Define one default constructor that initializes real and imaginary to 0. Note: A default constructor is a constructor with no parameters. Define a member function called print that uses cout to print the complex number in the format (a + bi) followed by a newline. This function has no parameters. Include the parenthesis symbols in the print out. If the imaginary part is negative (less than 0), print in the format (a - bi) followed by a newline. For example, if real is 6 and imaginary is -3, the output should look like this: (6 - 3i) It should not look like (6 - -3i) or (6 -3i) or (6-3i) Define a member function called set that sets both the real and imaginary data members. This function has 2 double parameters, one for each data member. Assign the real and imaginary data members respectively. Define two get functions, one for each data member, getReal() and getImaginary() that returns its respective data member. Any member function that does not inheritely modify the data members are defined with the const keyword to prevent data members from being modified in the function. For example, the print function does not modify the data members, so the header of the print should look like this: void print() const { Use my main() to test the your member functions: https://laulima.hawaii.edu/x/8s55cE There should be no errors present. If the spacing is off, then you may be missing a newline at the end of your print() function. Be sure to have a program description at the top and in-line comments. Be clear with your comments and output to the user, so I can understand what the program is doing. Comments are not required in main() if you used the provided one. See the commented version of the functions.cpp to see how to comment your member functions. Be sure to have read through the assignment policy for this class.
Please write your original code in c++ Thank you Objective Create a class named Complex to represent complex numbers. Use the main() function and create at least three complex number objects and test all member functions of the Complex class. How to use classes. Related SLO Develop properly structured multifile programs with automatic compilation. Use classes in C++. Instructions Create a program named LastnameFirstname18.cpp, that does the following: Note: This program has no user input. Define a class called Complex that will represent a complex number. Complex numbers have the form a + bi, where a is the real part and b is the imaginary part. Both the a and b coefficients are real numbers. i is the square root of negative one, but it's not actually implemented in code. For this assignment, you will only be working with a and b. Wikipedia page for Complex numbers: here Declare 2 private double data members: real and imaginary Define one default constructor that initializes real and imaginary to 0. Note: A default constructor is a constructor with no parameters. Define a member function called print that uses cout to print the complex number in the format (a + bi) followed by a newline. This function has no parameters. Include the parenthesis symbols in the print out. If the imaginary part is negative (less than 0), print in the format (a - bi) followed by a newline. For example, if real is 6 and imaginary is -3, the output should look like this: (6 - 3i) It should not look like (6 - -3i) or (6 -3i) or (6-3i) Define a member function called set that sets both the real and imaginary data members. This function has 2 double parameters, one for each data member. Assign the real and imaginary data members respectively. Define two get functions, one for each data member, getReal() and getImaginary() that returns its respective data member. Any member function that does not inheritely modify the data members are defined with the const keyword to prevent data members from being modified in the function. For example, the print function does not modify the data members, so the header of the print should look like this: void print() const { Use my main() to test the your member functions: https://laulima.hawaii.edu/x/8s55cE There should be no errors present. If the spacing is off, then you may be missing a newline at the end of your print() function. Be sure to have a program description at the top and in-line comments. Be clear with your comments and output to the user, so I can understand what the program is doing. Comments are not required in main() if you used the provided one. See the commented version of the functions.cpp to see how to comment your member functions. Be sure to have read through the assignment policy for this class.
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
Related questions
Question
Please write your original code in c++ Thank you
- Objective
- Create a class named Complex to represent complex numbers. Use the main() function and create at least three complex number objects and test all member functions of the Complex class.
- How to use classes.
- Related SLO
- Develop properly structured multifile programs with automatic compilation.
- Use classes in C++.
- Instructions
- Create a
program named LastnameFirstname18.cpp, that does the following: - Note: This program has no user input.
- Define a class called Complex that will represent a complex number.
- Complex numbers have the form a + bi, where a is the real part and b is the imaginary part. Both the a and b coefficients are real numbers. i is the square root of negative one, but it's not actually implemented in code. For this assignment, you will only be working with a and b.
- Wikipedia page for Complex numbers: here
- Declare 2 private double data members: real and imaginary
- Define one default constructor that initializes real and imaginary to 0.
- Note: A default constructor is a constructor with no parameters.
- Define a member function called print that uses cout to print the complex number in the format (a + bi) followed by a newline.
- This function has no parameters.
- Include the parenthesis symbols in the print out.
- If the imaginary part is negative (less than 0), print in the format (a - bi) followed by a newline.
- For example, if real is 6 and imaginary is -3, the output should look like this: (6 - 3i)
- It should not look like (6 - -3i) or (6 -3i) or (6-3i)
- Define a member function called set that sets both the real and imaginary data members.
- This function has 2 double parameters, one for each data member.
- Assign the real and imaginary data members respectively.
- Define two get functions, one for each data member, getReal() and getImaginary() that returns its respective data member.
- Any member function that does not inheritely modify the data members are defined with the const keyword to prevent data members from being modified in the function.
- For example, the print function does not modify the data members, so the header of the print should look like this:
void print() const {
- For example, the print function does not modify the data members, so the header of the print should look like this:
- Use my main() to test the your member functions: https://laulima.hawaii.edu/x/8s55cE
There should be no errors present. If the spacing is off, then you may be missing a newline at the end of your print() function. - Be sure to have a program description at the top and in-line comments.
- Be clear with your comments and output to the user, so I can understand what the program is doing.
- Comments are not required in main() if you used the provided one.
- See the commented version of the functions.cpp to see how to comment your member functions.
- Be sure to have read through the assignment policy for this class.
- Create a
![Example Output
% make
% ./program
Test the constructor.
Complex number complex1 is: (0+ 0i)
Test the one set() function.
Complex number complex2 is: (3.3 - 4.41)
Test the two get() functions.
Complex number complex3's real part is: 5.5
Complex number complex3's imaginary part is: 6.6
• Notes
o What goes in the public block:
■ Constructor, getters, setter, and print function
o What goes in the private block:
■ Declaration of data members
o Examples of classes from the lecture are fraction.cpp and functions.cpp](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb3203e91-4fc4-4599-9644-f518b38910cd%2F66994d5a-3d15-4d5b-ae44-a590877fe352%2Fptl5e8_processed.png&w=3840&q=75)
Transcribed Image Text:Example Output
% make
% ./program
Test the constructor.
Complex number complex1 is: (0+ 0i)
Test the one set() function.
Complex number complex2 is: (3.3 - 4.41)
Test the two get() functions.
Complex number complex3's real part is: 5.5
Complex number complex3's imaginary part is: 6.6
• Notes
o What goes in the public block:
■ Constructor, getters, setter, and print function
o What goes in the private block:
■ Declaration of data members
o Examples of classes from the lecture are fraction.cpp and functions.cpp
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education