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

  Implement the guess the word

Implement  the ‘Guess the Word' game in an object-oriented manner

  In c++, write a program that calculates 10,000 tries.

In C++, write a program that calculates 10,000 tries. These tries are based upon a rat trying to escape from a maze. Keep adding minutes until the rat is free and when he is free that is 1 try so we need 10,000. We start by randomly generating a numb..

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  A hierarchical jpeg encode decoder for greyscale images

This project is to develop a program that implements a hierarchical JPEG encoder/decoder for greyscale images.

  Properly store the number from variable value

1. Statement will properly store the number from variable  value  into the output file object AnsFile?

  Develop a simple poker game

Develop a simple poker game

  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

  A palindrome is a number

A palindrome is a number or text phrase that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 34543 and 11611. Write a program that reads in a five-digit integer and determines ..

  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.

  Write a program using vectors and iterators

Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulating it mathematically, eventually outputs your entire phone number. The d..

  Write a method named negative sum

Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative

  Write an lc-3 machine language program

Write an LC-3 machine language program starting at location x3000 which divides the number in memory location x4000 by the number in memory location x4001 and stores the quotient at x5000 and the remainder at x5001.

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