Using C++ 11 Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form: realPart + imaginaryPart * i Where i is  − 1 Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks: a) Adding two complex numbers: The real parts added together and the imaginary parts are added together. You should pass two objects to your function. b) Subtracting two complex numbers: The real parts subtracted together and the imaginary parts are subtracted together. You should pass two objects to your function. c) Printing Complex numbers in the form (a , b), where a is the real part and b is the imaginary part. (Do not use operator overloading for this assignment.)

Question

Using C++ 11

Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form:

realPart + imaginaryPart * i

Where is  − 1

Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks:

  1. a) Adding two complex numbers: The real parts added together and the imaginary parts are added together. You should pass two objects to your function.
  2. b) Subtracting two complex numbers: The real parts subtracted together and the imaginary parts are subtracted together. You should pass two objects to your function.
  3. c) Printing Complex numbers in the form (a , b), where a is the real part and b is the imaginary part.

(Do not use operator overloading for this assignment.)

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Object Oriented Programming

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Consider a program that declares global integer variables x, y[10]. Thesevariables are allocated sta...

A: Explanation of the code: lw $s1, 0($gp) #load value in base address to $s1addi $s1, $s1, 25 #increme...

Q: Vectors Write a for loop to print all NUM_VALS elements of vector courseGrades, following each with ...

A:  Note: As the user given index value is constant and so the value of index could not be changed whil...

Q: Write a program that begins by reading a number of cents from the users as an integer (this is input...

A: Initialize all required currency named variable with 0 in python3 programming language so that the u...

Q: hello good afternoon,   please, I need help with the following problem c++: ASSIGNMENT (CONTROL STRU...

A: A C++  program to display the song time and total time in a table format and a message indicating re...

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

Q: Discuss the roles of information in globalisation of business

A: Globalization of business:People, organization and governments are integrated or interacted word wid...

Q: Using the table structures you created (in first attachment called "Table Stucture", remove all tran...

A: Click to see the answer

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: The name of the program is CharCounter.inputEntry is a string type variable and used for storing use...

Q: What type of technique is used when an image is transferred by forcing ink through fine mesh or silk...

A: SerigraphySerigraphy also known as screen printing or silkscreen printing is a printing technique wh...

Q: This is my code for an MIPS assignment where im taking numbers into an array and reversing within th...

A: Note:For the given code and attached image, the following explanation is briefly described about the...

Q: Hi, I have to code a java program that accepts the ingredients for a recipe in cups and converts to ...

A: Create a class and a class method which will calculate the number of ounce from the number of cups (...

Q: Please explain, as simplistically (but thoroughly) as possible, how to develop a k-map from a truth ...

A: Rules to be followed to simplify the Boolean expression are given below-

Q: In python, write a program to find the prime factors of a number given by the user.

A: Program Instructions:Import the math module to use the sqrt() function.Take user input in a variable...

Q: Explain how to convert the letters A, B and C to decimal.

A: Decimal Number SystemDecimal number system is a base- 10 number system. It has 10 symbols, the symbo...

Q: Decrypt the following transposition cipher.  YREEOESXUAOYAWMZ What is the plain text? How many colu...

A: Given transposition cipher as:YREEOESXUAOYAWMZ

Q: Using DeMorgan's Law, write an expression for the complement of F if F(x,y,z) = xy + ~xz + y~z Show ...

A: Hello. Since you have posted multiple questions and not specified which question needs to be solved,...

Q: Python 3.7.4 Write a statement that associates d with an empty dictionary.

A: Following is the code statement to associate d with empty dictionary:A dictionary is an unordered, v...

Q: Draw the truth tables for the following Boolean expressions. xy+yz+xz x¯y+yz¯+x¯z (x⊕y)+(y⊕z)+(x...

A:  The logic gates are basically an elementary building block of the digital circuits. Logic gates are...

Q: Consider the following nested loop construct. Categorize its efficiency in terms of the variable n u...

A: The inner while loop runs n times as y=n. Hence, the big-o of the inner loop will be O(n).Next, in t...

Q: Write a program OrderCheck.java that takes four int command-line arguments w, x, y, and z. Define a ...

A: Program DesignThe program receives 4 integers at command prompt and ascertains if the numbers are in...

Q: Suppose you have two tables: EMPLOYEE and EMPLOYEE_1. The EMPLOYEE table contains the records for th...

A: Two tables are given named as EMPLOYEE and EMPLOYEE1. Each table has its records. EMPLOYEE table has...

Q: Write a program which does the following (name=xxx_Chapter81):1) Asks the user for the number of row...

A: Description:The following program is to print the two dimensional array.

Q: Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: ...

A: To add code segments in the below given program code, so that the code will print "Censored" if user...

Q: (Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a ...

A: The Java program is written to display first 100 emrip numbers which are nonpalindromic numbers whos...

Q: Write the code to assign the value 10 to an variable named a

A: The Java code is given below to assign the value 10 to a variable named ‘a’. There are two ways to a...

Q: Consider partitioning the list {1,4,0,1,1,1,2,3,1,0,4,4,1,2,0,1} where the first element ofthe array...

A: Program description for part (A)The program for part A works by using two new arrays for the left an...

Q: What is an example of an if else statement in C#?

A: The syntax for if-else statement in C# is:if(boolean_expression) {// stataments} else {   // statame...

Q: Hi, I just finished the code for writing a java program that accepts ingredients for a recipe in cup...

A: Begin the pseudocode with the description/goal of the program.Indent loop and condition constructs p...

Q: Linux servers 1. Cceate FOLDERNAME, script that gven a will create dinectocy named dircetory, and Su...

A: Open Linux editor using command "vi newclass.sh".To enter input in the empty editor with name newcla...

Q: in python   Write a program that prompts the user for three keyboard inputs and stores them in appro...

A: Following is the python program which takes three inputs from the user i.e. first name, last name an...

Q: 1. For the finite automaton below, find a minimal-state finite automaton accepting the same language...

A: Draw the table showing state transitions on different inputs:

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Program://import header fileimport java.util.Scanner; //definition of "PasswordChecker" classpublic ...

Q: Python 3.7.4 Shell HW3Q3.py C:/Users/kristen/Desktop/HW303.py (3.74 File Edit Shell Debug Options Rē...

A: DescriptionTo resolve the error i.e. TypeError: 'int' object is not callable, we must correct the pa...

Q: 1. (3.12 in 8e) What does the following program print? Note: Don't just give me the output - tell me...

A: 1)The given code snippet is used to print the squares of numbers from 1 to 10. It calculates the sum...

Q: What is the difference between Python and JavaScript coding?

A: JavaScriptIt is a web programing language.it is a cross- platform language.Its code is integrated wi...

Q: please solve this in python  //////////////// ////////////////   ////////////////   ////////////////

A: Program Instructions:Create three functions namely top(), body() and word() to print the different p...

Q: In the ER diagram for a Point of Sale system, there are entities such as Cashier, Product,Checkout, ...

A: The ER diagram of a Sale system includes different entities like Product, Transaction, Cashier, Chec...

Q: What is a hot spot and what are the benefits and cons?

A: Hotspot:A physical location that can obtain an internet access using Wireless Fidelity (Wi-Fi) is ca...

Q: Consider the information stored in your personal computer. Do you currently have information stored ...

A: “Yes”, most of the individual users store their sensitive and confidential information in the person...

Q: Suppose that a maximum flow network contains a node, other than the source node, without incoming ar...

A: Maximum flow problem:“Yes”, it is possible if the maximum flow network does not contain source node ...

Q: Blood alcohol content (BAC) is a measure of how much alcohol is in someone’s blood. It is usually me...

A: Program AlgorithmDeclare the required variables in the main().Get the input from the user for option...

Q: In python I have  N unique coupons that are included in boxes of the cereal being sold. A consumer w...

A: All the lines included after the #(hash) are python comments.To print the N unique coupons:for loop ...

Q: CHALLENGE 3.17.2: Conditional assignment. ACTIVITY Using a conditional expression, write a statement...

A: numUsers is incremented if updateDirection is equal to 1, else numUsers is decremented.

Q: What are the different companies providing NOS- Network Operating System?

A: A network operating system is basically an operating system which is developed to support PCs, works...

Q: In a file called RemoveVowels.java, write a program that: Asks the user to enter a word of text. Pr...

A:  First of all to import java.util.scanner object to use Scanner class. In java, you need to use the ...

Q: Describe the process of how to solve the substitution cipher below and solve it: ZFSZB YESUK SQYDJ S...

A: The process is as follows:scan to look for single letter words – they would most likely correspond t...

Q: Briefly discuss the advantages and disadvantages off frequent software upgrades

A:  Advantages of frequent software upgrades:Software upgrades can increase the performance of the syst...

Q: Write a C++ console application that allows your user to enter the total rainfall for each of 12 mon...

A: To write a C++ program that asks the user to enter total rainfall for 12 months into an array of dou...

Q: Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4...

A: Create a java program to pre-sell the cinema ticket.The name of the program is TicketSeller.The maxi...

Q: MIPS assembly language please help    Write a program for a grocery store to calculate the total cha...

A: Some definitions required to know before doing this program: -1.What is Mars?2.What is MIPS?3.What i...