Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please C++ programming 1. Create a class, called Complex, for modeling complex numbers, a+bi, and some complex mumber arithmetic/comparison operations. Here is what should be

Please C++ programming image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Create a class, called Complex, for modeling complex numbers, a+bi, and some complex mumber arithmetic/comparison operations. Here is what should be included within this class: Include a no-argument constructor (to initialize a complex number to 0:00 Include public member functions to perform these complex number tasks: Addition of complex numbers o Subtraction of complex numbers o Multiplication of complex numbers o Division of complex numbers o User input of a complex number o Display of a complex number o Conversion of a real number, r, to a complex number, r+ Oi o Check for equality of two complex numbers Then, write a CH program that will use the complex class to repeatedly do one of the following tasks: a) Perform a complex number arithmetic operation. For this option, the program will ask the user to enter a complex number, an arithmetic operation (+,-), and a second complex number, and will then calculate and display the result of performing the arithmetic operation on the two input complex numbers. b) Determine if a complex number is a solution of a quadratic equation. For this option, the program will prompt for and read in the real number coefficients, a, b, and c, of a quadratic equation, ar+bx+c=0. Next, it will prompt for and read in a complex number, 2. Then, it will determine if : is a solution of the quadratic equation. Note. When checking for equality of two complex numbers, do not use the "is equal to operator on the float values - instead, determine if the absolute value of the float values are smaller than a threshold value (something small, like 0.000001). To extract input of a complex number a + bi from keyboard, do the following: double a. b Complex Number Review A complex number is a number of the form a+bi where a and bare real numbers and i is the imaginary unit, i = -1 Addition/Subtraction: (a+bi)+(c + di)=(a tc)+(budi Multiplication: (a+bi) *(c + di) = (ac - bd) +(ad + bc) a+bi ac+bd bc-ad Division + c+di c+d2+d2 . Here is output from a sample run of the program (user input in bold): Select an option (1) perform complex number arithmetic I (2) check for quadratic equation solution (3) exit 1 Enter a complex number a+bi: 2+3i Enter an operation (+,-, /): + Enter & complex number a+b1: 4-81 2+31+ 4-3-6-51 Select an option (1) perform complex number arithmetic 12) check for quadratic equation solution (3) exit Enter a complex number atbi: 2493 Enter an operation (+,-) Enter a complex number bit 451 +91 4+51 +2441 Select an option (1) perform complex number arithmetic (2) check for quadratic equation solution (3) exit 1 Enter a complex number a+bi: 4421 Enter an operation (+,-, *. /): Enter a complex number atbi: 4-21 4+2i 1-2i - 20+01 I Select an option (1) perform complex number arithmetic (2) check for quadratic equation solution (3) exit 1 Enter a complex number a+bi: 4+81 Enter an operation (+,-,.,7): / Enter a complex number a+bi: 1-11 4+1 71-11-2+61 Select an option (1) perform complex number arithmetic (2) check for quadratic equation solution (3) exit 2. Enter the coefficients of a quadratic equation: 1-25 Enter a complex number a+bi: 1+21 The complex number: 1+21 19 a solution of the quadratic equation Select an option (1) perform complex number arithmetic (2) check for quadratic equation solution (3) exit 2 Enter the coefficients of a quadratic equation: 1 -2 5 Enter a complex number a+b: 2+31 The complex number: 2-31 = not a solution of the quadratse equation Focus I 2 I Enter the coefficients of a quadratic equation: 1 -2 5 Enter a complex number a+bi: 2+31 The complex number: 2+31 is not a solution of the quadratic equation Select an option - (1) perform complex number arithmetic (2) check for quadratic equation solution (3) exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions