Algorithms and programs to display properties of a triangle

Anonymous
timer Asked: Feb 7th, 2019
account_balance_wallet $60

Question Description

Assignment: Write algorithm(s) and program(s) to display certain properties of a given triangle — refer to P4.3 on page 172 in the text for the basics.

Output: Output will include all three Points, the lengths of all three sides, the three angles at the corners, the perimeter and the area of the triangle, and whether the triangle is Equilateral or Right-angled or neither — all in a nicely formatted layout, as directed. Values displayed will be labeled and designated in the appropriate “units”, angles will be displayed in “degrees”. All printed values will be rounded and formatted to four decimal-point accuracy, degrees rounded to the nearest degree.

Input: Program will prompt a user to provide x- and y-coordinates for the three Points of a triangle. User input must be validated. User prompts must clearly indicate how to enter values for each Point (which is: a pair of x- and y-coordinates, separated by a <return>). A coordinate is a floating-point value and can be positive, negative or zero.

Requirements: Use only material covered in the first six chapters - no arrays, no exceptions. Style requirements as discussed in class expected. Efficiency should always be considered. Round only for output. Choose the most appropriate loop/decision structures and variable types. No graphics.

Provide a Triangle class with only the appropriate constructor(s), methods and instance variables. Triangle class can only have three instance variables — for the three Points. Provide appropriate constants where useful. Provide appropriate accessor and mutator methods, as well as any required utility methods to compute values not stored in the class instance variables. Required methods: 2 constructors, 3 angle accessors, 3 side length accessors, perimeter accessor, area accessor, boolean right triangle utility, boolean equilateral triangle utility. Review chapter three (especially 3.2-3.3 pages 86-101) in the text for an example of, and valuable insights into, creating a class. Note that the utility methods are testing for equality of computed floating point values - refer to page 188, 5.2.2 for possible issues.

Also provide a separate Tester program (main) to prompt the user for the three Points, request the required values from the Triangle class, and then provide the display of the required output. All input/output will be handled by the Tester. See section 4.1 (pages 136-138) for hints on building class and tester programs. Test your programs completely and be sure your Tester tests all methods of your Triangle class!

The links: https://www.mathsisfun.com/algebra/trig-solving-triangles.html (Links to an external site.)Links to an external site. and https://www.mathsisfun.com/geometry/herons-formula.html (Links to an external site.)Links to an external site. may contain some useful triangle formulas. The link: http://www.mathopenref.com/tocs/triangletoc.html (Links to an external site.)Links to an external site. may provide some other triangle insights.

Use of the “Point” class is required - Appendix D (A17-18) in the text — java.awt.geom — along with page 67, may prove useful for Points.

Submission: Your program must be able to compile and execute on FIU SCIS, using the “java” compiler. Test it there before you submit.

Name your primary source code file: TriangleTester.java and your class source code file: Triangle.java . Only two source code files.

Refer to the Canvas documents: “How to Develop a Simple Java Program” and “Style Guide” documents for details on required program and class format and documentation. Review all documents carefully! Note: the class source code file will use the class heading documentation, the tester (main) source code will use the program heading documentation.

Algorithm (pseudocode) should be submitted for each program and in separate text files and included with the Canvas posting and class submission.

Print out a copy of your primary source code, class source code and pseudocode and submit in class — signed, stapled and collated in the specified sequence: primary source code (w/main) file, class source code file and then the pseudocode text files.

Post a .zip file — with all source code (.java) and text files — on the Canvas web site. Do not include any extraneous (e.g. IDE, output) files in the Canvas submission.

Program documentation must include the required signed disclaimer (comment) in the heading — no grade will be assigned to programs that omit the disclaimer or signature.

Sample Session:

Enter the x,y coordinates of three points in this order (x1,y1) (x2,y2) (x3,y3)

Separate each coordinate with a <return>:

0.0000

0.0000

2.0000

0.0000

0.0000

2.0000

Point 1 coordinates: (0.0000, 0.0000)

Point 2 coordinates: (2.0000, 0.0000)

Point 3 coordinates: (0.0000, 2.0000)

Side 1 length: 2.0000 units

Side 2 length: 2.8284 units

Side 3 length: 2.0000 units

Angle 1: 90 degrees

Angle 2: 45 degrees

Angle 3: 45 degrees

The perimeter of the triangle is 6.8284 units

The area of the triangle is 2.0000 square units

The triangle is Equilateral?: False

The triangle is Right-angled?: True

Algorithms and programs to display properties of a triangle
20190206190133.png

Unformatted Attachment Preview

Tutor Answer

andythewxman
School: UC Berkeley

Alright dude, here you go. There is a zip file attached. The files in the zip file are as follows:Triangle.java...

flag Report DMCA
Review

Anonymous
Top quality work from this guy! I'll be back!

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors