Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ thanks Program Specifications Your program will do the following 1. Ta

ID: 3882412 • Letter: U

Question

Using C++ thanks

Program Specifications Your program will do the following 1. Take as input four floating point values (in this order, as indicated): a. a real value and an imaginary value for the first complex number b. a real value and an imaginary value for the second complex number 2. Print the following four results: the sum, the difference, the product and the quotient of the 2 complex numbers. You will use exactly the following format: a. b. c. Each result on a single line (thus 4 lines printed) The precision is to two decimal point of accuracy (see note 1c below) output looks like the following exactly: 1 + 21 that is, a float, a space, a plus sign, a space, a float followed directly by the letter i Deliverables proj01/proj01.cpp . The name of the directory is proj01, the name file you turn in should be exactly proj01.cpp. It will be checked upon handing it in to Mimir for the first test case. Just like the lab, you must click on "Project 01 - complex number manipulation", the parent of the directory proj01, to submit the file. Assignment Notes: 1. We might as well try to make the output somewhat readable. You can look this up in the text or on the internet, but you can use the following modifiers that affect how numbers print. a. cout

Explanation / Answer

#include<iostream>
#include<stdlib.h>
#include<iomanip>

using namespace std;

int main(){
  
    double x1,y1,x2,y2;
    cout << "Enter real and imaginery part of first complex number :";
    cin >> x1>>y1;
    cout << "Enter real and imaginery part of second complex number :";
    cin >> x2>>y2;
    if ((y1 + y2) >= 0)
       cout << "Sum is :" << fixed << setprecision(2) << (x1+ x2) << " " << "+" << " " << y1+y2 << "i" << endl;
    else
       cout << "Sum is :" << fixed << setprecision(2) << (x1+ x2) << " " << "-" << " " << (-1) *(y1+y2) << "i" << endl;

    if ((y2 - y1) >= 0)
       cout << "Differnece is :" << fixed << setprecision(2) << (x2- x1) << " " << "+" << " " << y2-y1 << "i" << endl;
    else
       cout << "Differnece is :" << fixed << setprecision(2) << (x2 - x1) << " " << "-" << " " << (-1) *(y2-y1) << "i" << endl;

    if ((x1*y2+y1*x2) >= 0)
       cout << "Product is :" << fixed << setprecision(2) << (x1+ x2) << " " << "+" << " " << x1*y2+y1*x2<<"i" << endl;
    else
       cout << "Product is :" << fixed << setprecision(2) << (x1+ x2) << " " << "-" << " " << (-1) *(x1*y2+y1*x2) << "i" << endl;

   
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote