Calculating the Perimeter of a Shape

Calculating the Perimeter of a Shape

TOTAL POINTS 7
1.Question 1
What is the perimeter of the shape made from the file datatest4.txt whose contents are shown below (just give to two decimal places)?
-3, 9
-8, 7
-12, 4
-6, -2
-4, -6
2, -8
6, -5
10, -3
8, 5
4, 8
1 point
2.Question 2
What is the average length of a side in the shape made from the file datatest4.txt whose contents are shown below (just give to two decimal places)?
-3, 9
-8, 7
-12, 4
-6, -2
-4, -6
2, -8
6, -5
10, -3
8, 5
4, 8
1 point
3.Question 3
What is the longest side in the shape made from the file datatest4.txt whose contents are shown below (just give to two decimal places)?
-3, 9
-8, 7
-12, 4
-6, -2
-4, -6
2, -8
6, -5
10, -3
8, 5
4, 8
1 point
4.Question 4
What is the largest perimeter of a shape made from the shapes in files dataset1.txt, dataset2.txt, dataset3.txt, dataset4.txt, dataset5.txt, and dataset6.txt (just give to two decimal places)?
1 point
5.Question 5
What is the name of the file that has the shape with the largest perimeter from the four files example1.txt, example2.txt, example3.txt and example4.txt?
1 point
6.Question 6
The method getNumPoints returns the number of points in a Shape s.
Which one of the following is NOT a correct implementation of getNumPoints?
1 point
7.Question 7
Consider the following code for the function mysteryShape that has one parameter a Shape s and calls the function getNumPoints from the assignment.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public double mysteryShape (Shape s) {
double tmp = 0;
for (Point p : s.getPoints()) {
if (p.getX() > 0) {
if (p.getY() < 0) {
tmp = tmp + 1;
}
}
}
return tmp / getNumPoints(s);
}
Which one of the following best describes the purpose of this function?
1 point

تعليقات