Write the class definition for a class called complex

Assignment Help C/C++ Programming
Reference no: EM13162723

1. Write the class definition for a class called complex.

Complex numbers have the form

        realPart + imaginaryPart * i

where I is the square of (-1)

Use double variable 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 of 0 in case no initializers are provided. Provide public member functions that perform the following tasks:

a). setComplex function to set complex number to set the real part and imaginary part of the complex number

b). displayComplex function to print complex number in the form (a, b), where a is the real part and b is the imaginary part.

 

 

 

 

2. Write a C++ program to test your class by using the following main function.

int main ()

{

complex c1(1, 2), c2(3, 4), c3;

c1.display();

c2.display()

c3.display();

c3.setComplex(5, 6);

c3.display();

return 0;

}

 

 

Reference no: EM13162723

Questions Cloud

Mental disorders : In terms of mental disorders, most mental health professionals greatly attend to
Category of compulsions and mental disorder and diversity : Which is not a category of compulsions?  With regard to mental disorder and diversity, which statement(s) is/are true?
Major depression-bipolar disorder : In contrast to major depression, bipolar disorder,  is more common in the general population,  is more prevalent among women than men,  is more prevalent among married people,  usually occurs before age 30
Write a program which accepts the total of food and drink : Write a program which accepts the total of food and drink purchased for a restaurant bill as input. The output should be adjusted bill with a sales tax of six percent 6% and a tip (gratuity) of 15%.
Write the class definition for a class called complex : . Write the class definition for a class called complex.
Dealerships are awarded the rebate : Dealerships are awarded the rebate on a quarter-by-quarter basis, only for quarters where their actual sales exceeded expected volumes for that quarter. Expected sales volumes for each quarter are as follows:
B+-tree : For the B+-tree where M=3 and L=5 shown below, show how an insert of value 80 is handled.
Encryrption of some unknown : Assume (A1,B1) is an encryrption of some unknown m1. Prove that (A1,B2g^(m2) mod p) is a valid  encryption of m1 + m2 mod p. More generally, if (A2,B2) is an encryption of m2, what is (A1A2  mod p,B1B2 mod p) an encryption of?
Problem resolution in an organization. : In a one to two page (two page double-spaced maximum) paper explain why information systems today are currently effective or ineffective in assisting with problem resolution in an organization.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write program which prompts user to enter numbers

Write down the program which prompts the user to enter numbers, findsout how many positive and negative values have been entered, and calculates sum and average of numbers entered.

  An integer on this system is 4 bytes long

Assume the following for the program below. An integer on this system is 4 bytes long. The memory address where the array "a[]" was created begins at location 8000. a. #include

  Implement a semantic analysis

The program will implement Semantic Analysis. The assignment provides two options to define variable scope, either using the Global Option or the Local Option.

  Implementation of sorting technique

Implementation of sorting technique

  Write a c program that asks for and reads in two integers

Write a C program that asks for and reads in two integers and then reports if one is a multiple of the other.

  Create class has three pieces of information as data members

Create a class called Date in C++ that includes three pieces of information as data members: month (type int), day (type int) and yaer (type int).

  Design a deck plan space ship in eclipse

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls.

  Function that returns the height of a binary tree

Write a function called getHeight() that returns the height of a given binary tree - CptS 122 Write a function called countSmallerThan() that returns the number of nodes whose values are smaller than the supplied input paramter

  Create a class called point3d

Create a class called Point3D to represent 3D point in space, a class called Sphere and a class called Cylinder. The sphere is characterized by its center point and the radius while the Cylinder can be characterized by its center point, radius and he..

  Write program which reads n numbers from keyboard

Write down C++ program which reads N numbers (positive, negative, integer and double numbers) from keyboard, computes and shows the following information. Largest number of all numbers entered from keyboard.

  Give students practice in writing and calling their function

To give students practice in writing and calling their own functions. To give students practice in implementing and planning complex programs.

  The funtion should take as parameters

Write a function in c ++ that multiplies two functions. the funtion should take as parameters two fraction structures. Then, the function should multiply the two fractions and return the solution as a fraction structure.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd