id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > quiz2021_10_21_BONUS_vector
prev  |  next  |  chance

Write a method that accepts two vectors in {magnitude,angle} form, then returns the result of adding those two vectors, with your result also given in {magnitude,angle} form. The angle is the second element in each array and is given in radians, not degrees. You will only be given non-negative angles, and the results must also be given using non-negative angles. You may use any methods in the Math library, and you are allowed to access the Java API for the Math library by following this link: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html ...or by Googling "Java API Math". I highly recommend working this out on paper first! It is easier to convert to component form of the vectors, then add them in component form, then convert back to {magnitude,angle} form. Note: Because you need to convert to component form and back, you will get some values that are a little off. This should be consistent and therefore match my test data. For example: Given vectors {8.25,2.5} and {9.75,2.5} you SHOULD get {18.0,2.5}, but instead you get {18.0, 2.500000046410207}. That is to be expected because of the conversions back and forth. Enjoy!


quiz2021_10_21_BONUS_vector([15.8, 0.2], [7.35, 0.5]) → [22.924854480766356, 0.2948898732756141]
quiz2021_10_21_BONUS_vector([1253, 3.2], [1350, 0.1]) → [111.06247390756344, 0.5882832792103757]
quiz2021_10_21_BONUS_vector([124, 4.5], [100, 3]) → [164.7127275026403, 0.7078917444417925]

...Save, Compile, Run (ctrl-enter)

public double[] quiz2021_10_21_BONUS_vector(double[] a, double[] b) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy