Java Question

User Generated

Synzre

Programming

Description

the program has to be done with required materials only (I will provide the materials)

Unformatted Attachment Preview

Faculty of Computer Studies (FCS) TM105/M105: Introduction to Programming Tutor Marked Assignment (TMA) – Fall 2021-2022 Semester Cut-Off Date: TBA Total Marks: 20 This TMA deals with a mathematical project. You must submit the source file well documented in a Java project. Also, you must submit a single word file containing: - A copy and paste of all java code. - Snapshots of the program runs. - If your code does not completely work, attach some description to explain the status of the code and the runs. You have two submission links on your LMS page: • A submission link to upload a zipped folder of your Java project. • A submission link to upload the word file. IMPORTANT WARNINGS YOUR TMA WILL NOT BE MARKED IF NOT ALL THE REQUIRED FILES ARE SUBMITTED ON BOTH SUBMISSION LINKS. ANY ANSWERS OUT OF THE TMA MATERIAL (MEETINGS 1, 2, 3, 4) WILL NOT BE CONSIDERED. STUDENT WILL BE PENALIZED IF HE/SHE GET EXTERNAL SUPPORT. PLAGIARISM WARNING As per AOU rules and regulations, all students are required to submit their own TMA work and avoid plagiarism. The AOU has implemented sophisticated techniques for plagiarism detection. You must provide all references in case you use and quote another person's work in your TMA. You will be penalized for any act of plagiarism as per the AOU's rules and regulations. Declaration of No Plagiarism by Student (to be signed and submitted by student with TMA work): I hereby declare that this submitted TMA work is a result of my own efforts and I have not plagiarized any other person's work. I have provided all references of information that I have used and quoted in my TMA work. Name of Student: Signature: Date: OVERVIEW In the plane, the distance ̅̅̅̅ 𝐴𝐵 between two points 𝐴 = (𝑎𝑥 , 𝑎𝑦 ) and 𝐵 = (𝑏𝑥 , 𝑏𝑦 ) is computed based on the coordinates of the two points by the following equation: 𝐴(𝑎𝑥 , 𝑎𝑦 ) ̅̅̅̅ 𝐴𝐵 = √(𝑎𝑥 − 𝑏𝑥 )2 + (𝑎𝑦 − 𝑏𝑦 )2 𝐵(𝑏𝑥 , 𝑏𝑦 ) A Quadrilateral is a quadrilateral is a four-sided polygon while a polygon is a two-dimensional figure made up of straight sides represented in the coordinate plan. A quadrilateral also has four angles formed by its four sides. by four points A, B, C and D. Each quadrilateral point is identified in the plane by two values representing the x-coordinate and y-coordinate of the point; 𝒚𝒂𝒙𝒊𝒔 𝑩(𝒃𝒙 , 𝒃𝒚 ) 𝑨 = (𝒂𝒙 , 𝒂𝒚 ), 𝑩 = (𝒃𝒙 , 𝒃𝒚 ), 𝜽𝑩 𝑪(𝒄𝒙 , 𝒄𝒚 ) 𝜽𝑪 𝑪 = (𝒄𝒙 , 𝒄𝒚 ) and 𝑫 = (𝒅𝒙 , 𝒅𝒚 ) Quadrilateral perimeter is computed as the sum of the lengths of its 4 sides, i.e., 𝜽𝑨 𝑨(𝒂𝒙 , 𝒂𝒚 ) ̅̅̅̅ + 𝑩𝑪 ̅̅̅̅ + 𝑪𝑫 ̅̅̅̅ + 𝑨𝑫 ̅̅̅̅ 𝑷𝒆𝒓𝒊𝒎𝒆𝒕𝒆𝒓 = 𝑨𝑩 𝜽𝑫 𝑫(𝒅𝒙 , 𝒅𝒚 ) Quadrilateral area is computed with many formulas. One those formulas is: the area of a quadrilateral is the sum of areas of its 2 triangles formed by any of its 2 diagonals. As the area of a triangle computed as half the multiplication of any 2 sides multiplied by the sin of the angle between those 2 sides, the area of a quadrilateral may be computed as follows: 𝑨𝒓𝒆𝒂 = 𝒙𝒂𝒙𝒊𝒔 𝟏 𝟏 × ̅̅̅̅ 𝑨𝑩 × ̅̅̅̅ 𝑨𝑫 𝐬𝐢𝐧(𝜽𝑨 ) + × ̅̅̅̅ 𝑩𝑪 × ̅̅̅̅ 𝑪𝑫 𝐬𝐢𝐧(𝜽𝑪 ) 𝟐 𝟐 The three interior angles 𝜃𝐴 , 𝜃𝐵 , 𝜃𝐶 and 𝜃𝐷 of a quadrilateral with the four points A, B, C and D are computed as: 𝜽𝑨 = 𝒄𝒐𝒔 −𝟏 ̅̅̅̅𝟐 + 𝑨𝑫 ̅̅̅̅𝟐 − 𝑩𝑫 ̅̅̅̅̅𝟐 ̅̅̅̅𝟐 + 𝑩𝑪 ̅̅̅̅𝟐 − 𝑨𝑪 ̅̅̅̅𝟐 𝑨𝑩 𝑨𝑩 −𝟏 ( ) , 𝜽𝑩 = 𝒄𝒐𝒔 ( ) 𝟐 × ̅̅̅̅ 𝑨𝑩 × ̅̅̅̅ 𝑨𝑫 𝟐 × ̅̅̅̅ 𝑨𝑩 × ̅̅̅̅ 𝑩𝑪 ̅̅̅̅ 𝑪𝑫𝟐 + ̅̅̅̅ 𝑩𝑪𝟐 − ̅̅̅̅̅ 𝑩𝑫𝟐 𝜽𝑪 = 𝒄𝒐𝒔−𝟏 ( ), ̅̅̅̅ × 𝑩𝑪 ̅̅̅̅ 𝟐 × 𝑪𝑫 TM105 TMA – Fall 2021-2022 - KSA ̅̅̅̅ 𝑨𝑫𝟐 + ̅̅̅̅ 𝑪𝑫𝟐 − ̅̅̅̅ 𝑨𝑪𝟐 𝒂𝒏𝒅 𝜽𝑫 = 𝒄𝒐𝒔−𝟏 ( ) ̅̅̅̅ × 𝑪𝑫 ̅̅̅̅ 𝟐 × 𝑨𝑫 2 Implement a Java project according to the following specifications: 1. Reads from the user a number of quadrilaterals (minimum 15 quadrilaterals). 2. For each quadrilateral, it has to: a. Read from the user 8 integer values representing the x and y coordinates of the quadrilateral 4 points. b. Compute the lengths of the 4 sides of the quadrilateral by computing the distance between each pair to points of the quadrilateral using the above given equation of distance between 2 points in the plane. c. Calculate its 4 angles using the above give equation of computing the angle between any 2 straightline segments. d. Compute The quadrilateral perimeter; which is the summation of the 3 distances between the three points; i.e. 𝑷𝒆𝒓𝒊𝒎𝒆𝒕𝒆𝒓 = ̅̅̅̅ 𝑨𝑩 + ̅̅̅̅ 𝑩𝑪 + ̅̅̅̅ 𝑪𝑫 + ̅̅̅̅ 𝑨𝑫 e. The quadrilateral area, that is computed as a function of the quadrilateral sides and 2 of its interior angles, for example using the formula: 𝟏 𝟏 𝑨𝒓𝒆𝒂 = 𝟐 × ̅̅̅̅ 𝑨𝑩 × ̅̅̅̅ 𝑨𝑫 𝐬𝐢𝐧(𝜽𝑨 ) + 𝟐 × ̅̅̅̅ 𝑩𝑪 × ̅̅̅̅ 𝑪𝑫 𝐬𝐢𝐧(𝜽𝑪 ) f. Print the quadrilateral 4 sides, 4 interior angles, perimeter and area . 3. Print the average perimeter of the entered quadrilaterals. 4. Print the average area of the entered quadrilaterals. 5. Determine the quadrilateral with the maximum perimeter and print its perimeter and the coordinates of its four points. 6. Determine the quadrilateral with the maximum area and print its area and the coordinates of its four points. 7. Determine the quadrilateral with the maximum interior angle of all the quadrilaterals and print its maximum angle the coordinates of its four points. 8. A screenshot of the complete program outputs showing all the required values is required End of TMA, TM105 TMA – Fall 2021-2022 - KSA 3
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached explanation and answer. Let me know if you have any questions.The program and the Word file are ready. The program consists of two Java files, Quadrilateral.java (the class for quadrilaterals) and QTest.java (program that asks for 15 quadrilaterals and prints the findings). These Java files are in zip file, unzip them before use.Feel free to ask about any problems, I am here to help you.

Quadrilateral.java:
public class Quadrilateral
{
private int ax,ay,bx,by,cx,cy,dx,dy; // coordinates of 4 vertices

// constructor that takes 8 coordinates
public Quadrilateral(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy)
{
this.ax = ax;
this.ay = ay;
this.bx = bx;
this.by = by;
this.cx = cx;
this.cy = cy;
this.dx = dx;
this.dy = dy;
}

// returns x-coordinate of vertex num
// num may be any integer, num % 4 is used
private int getVertexX(int num)
{
num = num % 4;
if(num == 0)

return ax;
else if(num == 1)
return bx;
else if(num == 2)
return cx;
else
return dx;
}

// returns y-coordinate of vertex num
/...


Anonymous
Just the thing I needed, saved me a lot of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags