I have been trying to figure this out for a little while and I really can't seem to get a good grasp on where I am messing this thing up. I keep getting errors:
Error 2 error C2664: 'input_polar' : cannot convert parameter 2 from 'int' to 'double &'
Error 3 error C2062: type 'void' unexpected
And also my variables within my void statement keep telling me that they are undeclared identifiers C2065.
I kinda understand the first error as the polar input has an integer angle within it, but if I make my angles double then i get this error:
Error 1 error C2664: 'rec_to_polar' : cannot convert parameter 4 from 'double' to 'int &'
I understand the error, just not how to fix it. As for the void unexpected I really do not get that because i told the program I was going to have the void functions at the beginning and I think that is why it is messing up my variables as well.
As for 7 and 8 I have not yet put the function I am going to use in quite yet but they will both deal with the same variables and functions so I would need to finish fixing those errors which in return would correct what I have left to input.
Any help would be greatly appreciated. Thanks in advance.
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
void input_rec(double& real, double& imag);
void rec_to_polar(double& real, double& imag, double& mag, int& ang);
void input_polar(double& real, double& imag);
void polar_to_rec(double& real, double& imag, double& mag, int& ang);
//begin main function
const double PI = 4*atan(1.0);
int main()
{
double reA = 0.0;
double magA = 0.0;
double imgA = 0.0;
double reB = 0.0;
double magB = 0.0;
double imgB = 0.0;
double reC = 0.0;
double magC = 0.0;
double imgC = 0.0;
int angA = 0;
int angB = 0;
int angC = 0;
int choice;
do
{
system("cls");
cout<<"Complex Number A: Real: "<<reA<<"Imaginary: "<<imgA<<"Magnitude: "<<magA<<"Angle: "<<angA<<endl;
cout<<"Complex Number B: Real: "<<reB<<"Imaginary: "<<imgB<<"Magnitude: "<<magB<<"Angle: "<<angB<<endl;
cout<<"Complex Number C: Real: "<<reC<<"Imaginary: "<<imgC<<"Magnitude: "<<magC<<"Angle: "<<angC<<endl;
cout<<endl;
cout<<"1. Enter Complex Number A in Rectangular Form."<<endl;
cout<<"2. Enter Complex Number A in Polar Form."<<endl;
cout<<"3. Enter Complex Number B in Rectangular Form."<<endl;
cout<<"4. Enter Complex Number B in Polar Form."<<endl;
cout<<"5. Add the two Complex numbers together: C = A + B"<<endl;
cout<<"6. Find the Complex Conjugate: C = A*."<<endl;
cout<<"7. Multiply the two Complex Numbers: C = AB"<<endl;
cout<<"8. Divide the two Complex Numbers"<<endl;
cout<<"9. End the Program."<<endl;
cout<<endl;
cout<<endl;
cout<<"Please select an option."<<endl;
cin>>choice;
switch(choice)
{
case 1:
input_rec (reA,imgA);
rec_to_polar (reA,imgA,magA,angA);
break;
case 2:
input_polar (magA,angA);
polar_to_rec (reA,imgA,magA,angA);
break;
case 3:
input_rec (reB,imgB);
rec_to_polar(reB,imgB,magB,angB);
break;
case 4:
input_polar (magB,angB);
rec_to_polar (reB,imgB,magB,angB);
break;
case 5:
reC = (reA+reB);
imgC = (imgA+imgB);
rec_to_polar (reC,imgC,magC,angC);
break;
case 6:
reC = reA;
imgC = imgA*-1;
rec_to_polar(reC,imgC,magC,angC);
break;
case 7:
cout<<"7"<<endl;
break;
case 8:
cout<<"8"<<endl;
break;
default:
cout<<"Invalid Choice"<<endl;
}
while(choice != 9);
system("pause");
return 0;
}
void input_rec(double& real, double& imag);
{
cout<<"Input the real part"<<endl;
cin>>real;
cout<<"Input the imaginary part"<<endl;
cin>>imag;
}
void rec_to_polar(double& real, double& imag, double& mag, int& ang);
{
mag = sqrt(real*real+imag*imag);
ang = (atan2(imag,real))*(180.0/PI);
}
void input_polar(double& real, double& imag);
{
cout<<"Enter the Magnitude"<<endl;
cin>>mag;
cout<<"Enter the angle"<<endl;
cin>>ang;
}
void polar_to_rec(double& real, double& imag, double& mag, int& ang);
{
real = mag*cos(double((ang*PI)/180.0));
imag = mag*sin(double((ang*PI)/180.0));
}