Question: Objective: This assignment will help you review the ArrayList class as a type - safe generic data type. Program assignment: Build an ADT for vectors.

Objective: This assignment will help you review the ArrayList class as a type-safe generic data type.
Program assignment: Build an ADT for vectors.
Your program should have the following header:
A vector x consists of n real components x1,x2,dots,xn. The operations between two vectors ,
{:xn] and y=[y1,y2,dots,yn] are defined as follows:
addition
x1+y1,x2+y2,dots,xn+yn
subtraction
x1-y1,x2-y2,dots,xn-yn
dot-product
x*y=x1**y1+x2**y2+dots+xn**yn
equivalence
x==yif(x1=y1 and x2=y2 and dots and xn=yn)
scalar-product
s**x=[s**x1,s**x2,dots,s**xn], where s is a real number.
absolute-value
|x|=?2(x*x)
You should have two constructors:
a. One constructor, with parameters (double [] initvalues), where initvalues are
the initialization values for the new vector.
b. The copy constructor.
You should have an accessor function for the k-th components of a vector.
You should have member functions for arithmetic: plus () and minus () which, for example, would
be used as: x=y.plus(z), where x,y, and z are MyVector objects.
You should have a member function for scaling: scaledBy () which, for example, would be used as:
x=y*scaledBy(s), where x and y are MyVector objects, and s is a real number.
You should override the toString () method for display on System. out
You should override the equals () method.
You should create an absolute value function: abs ()
You should build a dot product function: dot () Design specifications
Create a Java project project 8 and a package package 8
Call your class MyVector. Define a second class containing a main method that exercises the class
MyVector as an application. That is, a main method that runs through a selection of arithmetic and
logical operations and uses MyVector output. The two classes should be saved in two different files.
Your class MyVector should keep the vector in an ArrayList
 Objective: This assignment will help you review the ArrayList class as

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!