Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago