Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me debug my Java code! These are the errors I got: HW 2 _ Tester.java: 2 0 6 : error: cannot find symbol
Please help me debug my Java code!
These are the errors I got:
HWTester.java:: error: cannot find symbol
MathVector sum new MathVectorvectorsgetDimension;
symbol: variable vectors
location: class MathVector
HWTester.java:: error: cannot find symbol
forMathvector vectors : vectors
symbol: variable vectors
location: class MathVector
HWTester.java:: error: cannot find symbol
forMathvector vectors : vectors
symbol: class Mathvector
location: class MathVector
errors
error: compilation failed
This is my code:
class MathVector
private final int dim;
private final double values;
public MathVectorint N
this.dim N;
this.values new doubledim;
public MathVectordouble arr
dim arr.length;
values new doubledim;
for int i ; i dim; i
valuesi arri;
public MathVectorMathVector v
thisvvalues
dim vdim;
values new doubledim;
for int i ; i dim; i
valuesi vvaluesi;
public static MathVector vecDfromPolardouble r double theta
double x r Math.costheta;
double y r Math.sintheta;
return new MathVectorxy;
public static MathVector vecDfromPolardouble r double theta, double phi
double x r Math.sintheta Math.cosphi;
double y r Math.sintheta Math.sinphi;
double z r Math.costheta;
return new MathVectorx y z;
public int getDimension
return dim;
public double getValueint idx
return valuesidx;
public void setValueint idx, double val
valuesidx val;
public double dotWithMathVector other
double dotProd ;
forint i ; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started