I want to create a program that asks the user to enter two vector (size and direction), and calculates its addition through turning it into components (using OOP).
here's what I've got so far (I don't know how to fix the errors), I'm not sure what's wrong/ to do next (vector 1 has a magnitude of 1 and 60 degrees while vector 2 has 2 and 50 degrees):
#include<iostream>
#include<cmath>
using namespace std;
// A class declaration for class Complex
// This class creates complex number objects z = x + i*y,
// where x is the real and y the imaginary part
class Vector
{
Public:
Vector();
void assign (double x, double y);
void convert (double x, double y);
Vector modulus();
Vector operator+(const Vector &z);
Vector operator-(double xsize, double ysize);
void Vector::assign(double x, double y){
double size = x;
double degree = y;
}
void Vector::convert(double x, double y){
double xsize = size*cos(degree/180.0);
double ysize = size*sin(degree/180.0);
}
Vector Vector::operator(const Vector &z){
Vector temp;
Vector xsize=(*this).xsize+z.xsize;
Vector ysize=(*this).ysize+z.ysize;
return Temp;
)
Vector Vector::modulus(){
resultantvec= sqrt(xsize*xsize + ysize*ysize);
return resultantvec;
}
Vector Vector::operator-(double xsize, double ysize){
resultantrad=atan2(ysize/xsize);
resultantdeg=resultantrad*180;
return resultantdeg;
}
//Below, the main()
int main(){
Vector num1;
Vector num2;
num1.assign(1,60);
num2.assign(2,50);
cout<<"the resultant vector is"<<resultantvec<<"at an angle of" resultantdeg<<endl;
return 0;
}
Thanks a lot for the help!