#include<iostream>
#include<math.h>
using namespace std;
struct complexNumber
{
float real;
float imaginary;
}a,b,c,x,y,z;
int main()
{
cout<<"Hello user!\n";
cout<<"Enter real and imaginary part of 1st complex number:";
cin>>a.real>>a.imaginary;
cout<<"Entered first complex number= "<<"("<<a.real<<")"<<"+"<<"("<<a.imaginary<<")"<<"i";
cout<<"\nEnter real and imaginary part of 2nd complex number:";
cin>>b.real>>b.imaginary;
cout<<"Entered second complex number= "<<"("<<b.real<<")"<<"+"<<"("<<b.imaginary<<")"<<"i";
if(a.real==b.real && a.imaginary==b.imaginary)
{
cout<<"\ncomplex numbers a and b are equal.";
}
if(a.real!=b.real || a.imaginary!=b.imaginary)
{
cout<<"\ncomplex numbers a and b are not equal.";
}
c.real=a.real+b.real;
c.imaginary=a.imaginary+b.imaginary;
cout<<"\nAddition of a and b: "<<"("<<c.real<<")"<<"+"<<"("<<c.imaginary<<")"<<"i";
c.real+=a.real;
c.imaginary+=a.imaginary;
cout<<"\nAddition of a to c: "<<"("<<c.real<<")"<<"+"<<"("<<c.imaginary<<")"<<"i";
c.real-=b.real;
c.imaginary-=b.imaginary;
cout<<"\nSubtraction of b from c: "<<"("<<c.real<<")"<<"+"<<"("<<c.imaginary<<")"<<"i";
c.real=a.real-b.real;
c.imaginary=a.imaginary-b.imaginary;
cout<<"\nSubtraction of a and b: "<<"("<<c.real<<")"<<"+"<<"("<<c.imaginary<<")"<<"i";
c.real=((a.real)*(b.real))-((a.imaginary)*(b.imaginary));
c.imaginary=((a.real)*(b.imaginary))+((b.real)*(a.imaginary));
cout<<"\nProduct of a and b: "<<"("<<c.real<<")"<<"+"<<"("<<c.imaginary<<")"<<"i";
x.real=y.real=z.real=c.real;
x.imaginary=y.imaginary=z.imaginary=c.imaginary;
cout<<"\ncomplex number x= "<<"("<<x.real<<")"<<"+"<<"("<<x.imaginary<<")"<<"i";
cout<<"\ncomplex number y= "<<"("<<y.real<<")"<<"+"<<"("<<y.imaginary<<")"<<"i";
cout<<"\ncomplex number z= "<<"("<<z.real<<")"<<"+"<<"("<<z.imaginary<<")"<<"i";
x.real=(double)x.real;
x.imaginary=(double)x.imaginary;
cout<<"\ncomplex number x type-cast to a double= "<<"("<<x.real<<")"<<"+"<<"("<<x.imaginary<<")"<<"i";
}
Please provide source code, make a program that follows everything on this doc. te a complete...
Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...
This is a fill in the code type: // FILL IN THE CODE - Write a program to multiply 2 numbers, print out the results and print out the original numbers in ascending order. #include <iostream> using namespace std; int main() { int num1; // holds 1st number int num2; // holds 2nd number int result; // holds result of multiplication int *num1Ptr = nullptr; // int pointer which will be set to point to the 1st number int *num2Ptr...
Write a program in C++. You need everything everythihng given You will create a function that validates input. It should accept only non-negative integers. If the input is incorrect the function should throw an exception. The exception will not be caught in the function. You will create a function that reads in 2 integer values. One is a number that will be raised to the power of the second. So if 5 and 6 are entered the result would be...
this should be a code for C++ the source code file so the program will operate as described below. These are the software requirements for the project. When the program runs, it shall display the text as shown on lines 1-11 in the example below. Next, it shall display a prompt message asking the user to enter his or her yearly salary. Next, it shall shall read the user's salary from the keyboard (in the example below, user input is...
Please make a JAVA program for the following using switch structures Write a program that simulates a simple Calculator program. The program will display menu choices to the user to Add, Subtract, Multiply and Divide. The program will prompt the user to make a selection from the choices and get their choice into the program. The program will use a nested if….else (selection control structure) to determine the user’s menu choice. Prompt the user to enter two numbers, perform the...
c++ I am suppose to write a function that gets a number from a user, say 3.123456789 and then the program gets another number from the user which is used to find out how many decimal digits we want rounded to. So if the user inputs 3 then the number would turn into 3.123 then we are suppose to add two digits next to the rounded number so it would turn into 3.12300. the rounding is suppose to be done...
61. The following program is accepted by the compiler: int sum( int x, int y ) { int result; result = x + y; } T__ F__ 62. The following implementation is accepted by the compiler: void product() { int a; int b; int c; int result; cout << "Enter three integers: "; cin >> a >> b >> c; result = a * b * c; ...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...
c++, use the skeleton code to make a program of the following include <iostream> tinclude <string> using namespace std; class car public: //define your functions here, at least 5 private: string name; int mpg; double price int horsepower; // feel free to add more atributes int main() // create you objects, call your functions // define member functions here For this lab, write a program that does the following: Creates a class based on the car skeleton code (you may...
IP requirements: Load an exam Take an exam Show exam results Quit Choice 1: No functionality change. Load the exam based upon the user's prompt for an exam file. Choice 2: The program should display a single question at a time and prompt the user for an answer. Based upon the answer, it should track the score based upon a successful answer. Once a user answers the question, it should also display the correct answer with an appropriate message (e.g.,...