# Project #27273 - jave questions

im gonna send the previus codes,, and i did attache the previus assignment which i got 13 out of 20 on it,, and the doctor's comiints are including..

thank u,

Due: Friday 11th before class.

As usual for all questions submit sample input and output when appropriate.

Question 1

Take your MyPoint class from the previous assignment and add setters for the X and Y variables, so methods:

• void setX(double x)

• void setY(double y)

Question 2

Write a class called Triangle2D to represent a triangle in the plane (2 dimensional space). The class

must contain:

• Three points p1, p2 and p3 of type MyPoint (MyPoint from your last assignment).

• Getter methods for the three points.

• A constructor that constructs a point with specified points (NOT doubles, use MyPoints) as coordinates.

• A no-argument constructor that creates the triangle with points (0, 0), (1, 1) and (2, 5) – this constructor must call your previous constructor.

• A non-static method double getPerimeterLength() that returns the length of the perimeter of a triangle.

Write a main class as follows:

Triangle2D t = new Triangle2D(); double len = t.getPerimeterLength();

Carefully explain how the triangle is constructed. Draw pictures for the various objects involved, and show what variables or object fields refer to what other objects.

Also carefully explain how the getPerimeterLength method is called. Draw pictures for the various object, show what this refers to during the call, etc.

Question 3

Write a main class as follows:

MyPoint p = new MyPoint(0, 0);
MyPoint q = new MyPoint(1, 10);
MyPoint r = new MyPoint(10, 1); Triangle2D t = new Triangle2D(p, q, r); System.out.println(t.getPerimeterLength());

r.setX(200); System.out.println(t.getPerimeterLength());

Carefully (very carefully!) explain why the result of t.getPerimeterLength() has changed (draw pictures for the various objects involved, and show what variables or object fields refer to what other objects, etc).

Comment on what your results suggests from a software engineering perspective ... Question 4

Write a method that reads numbers (doubles) from they keyboard into a LinkedList until a zero is input (do not include the 0 in the list of numbers) and then prints:

• the maximum of the list of numbers

• the minimum of the list of numbers

• the sum of the numbers

• the number of times the first element of the list is repeated in the list.

Note:

• Do NOT use the min and max routines in class Collection.

• To iterate over the list you must use an iterator and NOT the get(int) method in class LinkedList.

 Subject Computer Due By (Pacific Time) 04/11/2014 06:00 am
TutorRating
pallavi

Chat Now!

out of 1971 reviews
amosmm

Chat Now!

out of 766 reviews
PhyzKyd

Chat Now!

out of 1164 reviews
rajdeep77

Chat Now!

out of 721 reviews
sctys

Chat Now!

out of 1600 reviews

Chat Now!

out of 770 reviews
topnotcher

Chat Now!

out of 766 reviews
XXXIAO

Chat Now!

out of 680 reviews