Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 Consider the Vector 2 D class. We want to add multiplication methods in this class. If a vector is multiplied by a real number,

2 Consider the Vector2D class.
We want to add multiplication methods in this class. If a vector is multiplied by a real number, then
both x and y values are simply multiplied by that real number. If it is multiplied by another vector
v, then it will follow the rule of dot product. Dot product of two vectors u&v,u.v=u.x**v.x+
u. Y ?**.y. In this Vector2D class, write two overloaded methods for multiplication;
A. One method takes a double parameter, does the real number multiplication, then returns a
Vector 2D object and
B. The other one takes a Vector2D parameter, does the dot product and then returns a double
number.
public class Vector2D{
double x,y;
Vector2D()1
x=0;
y=0;
}
Vector2D(double x, double y)
this. x=x;
this. y=y i
}
}
image text in transcribed

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

3. How frequently do the assessments occur?

Answered: 1 week ago