Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Edit the given code please. Create a MathVector object. Have it accept an integer array of three values. Then calculate the magnitude of this vector

image text in transcribedEdit the given code please.

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. 3 If you look in the file MathVector.java you'll see there is a way to calculate the magnitude of a vector: / * Returns the euclidean distance of this vector. * 9 1- import java.util. Random; 2 import java.util.stringjoiner; 4- public class preLabc { 5 6 public static double myMethod(int[] threevaluevector){ 7 8 // Create an object of type "Mathvector". Mathvector vectorobjecti = new Mathvector(threevaluevector); 12 // calculate the magnitude on the object by using the magnitude method. 12 // form: double theoutput = objectName DOT magnitude parenthesis parenthesis 13 double... // fill in here. 14 15 // return the double value here. 16 return theMagnitude; 17 18 } 19 } 11 nuBfbgn888 * @return the euclidean distance of this vector */ public double magnitude() { double sum = %; 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. 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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions