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 to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

  Declare a vector

Declare a vector of these structures where the size of the vector is to be 7.

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Data from the file grocery.dat

Read the data from the file Grocery.dat and assign values to the 10  GroceryItem  objects. Next display these items to allow a customer to select grocery items from the list and indicate the quantity of that item he or she would like to order. When t..

  Prepare a linux shell

Prepare a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as

  Program to compute surface area of sphere using function

Write down a program in C++ to compute surface area of sphere using a function. As sample run, write down the surface areas of spheres with radii.

  Develop a simple poker game

Develop a simple poker game

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  Write the output of the program

Design a C++ program that will interactively prompt for and read the name of the input file interactively prompt for and read the name of a file to write the output of the program to write the following to the specified output file your name, sect..

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

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