Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Script Create a MathVector object. Have it accept an integer array of three values. Then calculate the magnitude of this vector using the magnitude

image text in transcribedJava Script

Create a MathVector object. Have it accept an integer array of three values. Then calculate the magnitude of this vector using the magnitude method described in MathVector.java. If you look in the file MathVector.java you'll see there is a way to calculate the magnitude of a vector: 5 6 7 8 9 Returns the euclidean distance of this vector. 1- limport java.util. Random; 2 'import java.util.stringjoiner; 3 4- public class preLabc { public static double myMethod(int[] threevaluevector){ // Create an object of type "Mathvector". Mathvector vectorobjecti = new Mathvector(threevaluevector); 10 11 // calculate the magnitude on the object by using the magnitude method. 12 // form: double theoutput = objectName Dot magnitude parenthesis parenthesis double... // fill in here. 14 15 // return the double value here. return theMagnitude; } 13 * @return the euclidean distance of this vector */ public double magnitude() { double sum = 0; for (var e : array) { sum += Math.powle, 2); } return Math.sqrt(sum); } Two tests will be performed, each will send in a 3 value vector and you need to return double floating point value of the magnitude each time. 16 17 18 19 20 } To calculate the magnitude on the object you use MathVector.java's magnitude method. It has the form double theOutput = objectName DOT magnitude parenthesis parenthesis which could look something like double the MagnitudeValue = myObject.magnitude(); What to reproduce this on your own machine? Here are some important files: * preLabC.java (fill this in) MathVector.java (the class with all the methods that the student should explore) MyTest.java (the JUnit testing file. Student can use this on their own computer if they wish)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Find the percentage ionization of naproxen with pka 4.2 and pH 4

Answered: 1 week ago