Home Page > > Details

ITE3101 Introduction to Programming

 ITE3101 Introduction to Programming

 
Programming Assignment
 
 
Notice to Students
 
1. This assignment should be written by individual student. All downloaded materials are not allowed.
 
2. Plagiarism will be treated seriously. All assignments that have been found involved wholly or partly in plagiarism (no matter these assignments are from the original authors or from the plagiarists) will score ZERO marks.
 
3. Your program must use Java JDK7 or above to develop.
 
4. Your program must be structured and well commented.
 
The first few lines in the source file must be comments stating the name of the source file, student name, student ID, course name, course code, and brief description of your program.
 
/********************************************************
Name of Source File: xxxxx.java
 
Student Name (ID):
 
Course Name (Code):
 
Program Description:
This program is . . . . . . .
. . . . .
. . . . .
********************************************************/
 
Marks will be deducted if such comments are not included.
 
 
5. Write down your test cases and the reason(s) for them.  Test your program by using your test cases.
 
6. You are required to hand a zip file containing the following 2 items via the assignment link in Moodle:
 
a. Program code of your java file, including detailed comments
b. Input file to show your test cases
 
8. Weight of this assignment is 20% of the module total assessment.
 
 
Checking the Types of Triangle
 
Background
 
There are three types of triangles that are involved in this assignment, as follows:
 
 
 
For any triangle with the 3 sides of length "a", "b" and "c" respectively, some of its properties are as follows:
 
i. The length of each side can be calculated via the coordinates of the two vertices (x1, y1) and (x2, y2) connecting the side by using the formula:
 
 
 
ii. The conditions to form a valid triangle are:
 
a > 0, b > 0, c > 0
a + b > c
b + c > a
c + a > b
 
 
iii. The condition to form a valid Right-angled triangle is:
 
 
where
 
 
iv. The condition to form a valid Isosceles triangle is:
 
or or
 
 
v. The condition to form a valid Scalene triangle is:
 
 
 
 
vi. The area of the triangle can be calculated by the formula:
 
 
where
 
 
Requirements
 
Given a set of (x, y) coordinates representing the vertices of triangles, write a Java program to check the types of all the triangles formed by selecting any three given vertices. The following shows an example displaying all possible triangles formed from 6 vertices.
 
 
 
Tasks
 
1. Write appropriate methods to do the following tasks, one method for each:
 
- Given the coordinates of the two vertices of a side of a triangle, calculate its length.
- Given the length of the three sides of a triangle, calculate its area.
- Given the length of the three sides of a triangle, check if it is a valid triangle.
- Given the length of the three sides of a triangle, check if it is right-angled.
- Given the length of the three sides of a triangle, check if it is isosceles.
- Given the length of the three sides of a triangle, check if it is scalene.
 
2. Input the coordinates of the vertices of triangles from a text file. Each row represents the (x, y) coordinates of a vertex of a triangle, and the two coordinate integers should be read into two integer array representing the x and y coordinates of all vertices. The last row (999, 999) is used to indicate end-of-file and should not be used as formal data.
 
An example input text file is shown below:
 
vertices.txt
-5 2
0 2
8 2
8 -11
4 2
4 5
999 999
 
3. Using appropriate iterations to select all the triangles formed by choosing any three vertices inputted in (1).
 
- For each triangle, check and display its types.
 
- Find and display the triangle with maximum area and the one with minimum area. The format of the maximum and minimum area is having 2 decimal places only.
 
For example, the format of the output of the program is shown below:
 
 
 
 
Assessment scheme
 
- Problem solving technique, e.g. algorithms (15 marks)
- Java programming technique, e.g. statements, control structures, etc. (15 marks)
- Programming style, e.g. naming, comments, etc. (10 marks)
- Testing, e.g. test cases, test results etc. (10 marks)
 
 
 
--- END ---
Contact Us - Email:99515681@qq.com    WeChat:codinghelp
Programming Assignment Help!