Project 80: Adding Vectors

Intro Problem: Suppose you left your house and first walked 3 miles east and 2 miles south to get to a resting stop.  Then you walk 1 mile west and 4 miles north to get to a friend's house.


Your friend's house is 2 miles north and 2 miles east of your house.

An example of vector addition is shown above.  Vector u = <3, -2> and vector v = <-1, 4>.  The sum u + v = <2, 2>.  Notice that when tail of the second vector is placed at the tip of the first vector, the result is equal to the sum.


Project 80: Variables 'x1', 'y1', 'x2', and 'y2' have been initialized.  

x1 is the x-component of the first vector (3 in the first example)

y1 is the y-component of the first vector (-2 in the first example)

x2 is the x-component of the second vector (-1 in the first example)

y2 is the y-component of the second vector (4 in the first example).

Task:  Appropriately initialize the values of 'sumX' and 'sumY' which represent the x and y components of the sum.


Note: The following trig methods are available.

cosine(x) 

sine(x) 

tangent(x) 

cosineInverse(x)

sineInverse(x)

tangentInverse(x)

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0