Question: Define a class called Complex which consists two private data x and y with double type and three public member functions: a constructor Complex (),
Define a class called Complex which consists two private data x and y with double type and three public member functions: a constructor Complex (), void setNumber(double, double), void printNumber(). In the function setNumber, you need to verify if the values of x and y are located between 0 and100. If not set the value to be 0.0. In the printNumber(), print the following message:
( xx.xx, x.xx)
where x is a digit. In your main program, use keyboard to input an array size. Next, use new to create an array of type Complex with inputted size. Then, prompt user to input the values of x and y, and call setNumber() for each array element. Finally, call printNumber() to display the complex numbers for all objects. Sample output:
Enter an integer for array size: 3
Enter two real numbers for a complex: 12.23 2.3 (repeat 3 times)
There are 3 complex numbers:
(12.23, 2.30)
(2345.45, -123.89)
(0.00, 2.00)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
