melina
چهارشنبه 05 بهمن 1384, 17:39 عصر
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 radical -1
use double variables to represent the private data of the class. provide a constructor that enables an object of this class to be initializers when it is declared
the constructor should contion default values in case no initializers are provided.provide public member functions for each of the following: a) Adding two complex numbers :the real parts are added together and the imaginary parts are added together
b) subtracting two complex numbers: the real part of the right operand is subtracted from the real part of the left operand , and the imaginary part of the right operand is subtracted form the imaginary part of the left operand
c) printing complex numbers in the from (a,b) , where a is the real part and b is the imaginary part
write a program to test your class
complex numbers have the form
realpart + imaginarypart *i where i is radical -1
use double variables to represent the private data of the class. provide a constructor that enables an object of this class to be initializers when it is declared
the constructor should contion default values in case no initializers are provided.provide public member functions for each of the following: a) Adding two complex numbers :the real parts are added together and the imaginary parts are added together
b) subtracting two complex numbers: the real part of the right operand is subtracted from the real part of the left operand , and the imaginary part of the right operand is subtracted form the imaginary part of the left operand
c) printing complex numbers in the from (a,b) , where a is the real part and b is the imaginary part