Question: Hello, this is my Java assignment. I could not figure it out, so I needed help. I would be grateful if someone could help me

Hello, this is my Java assignment. I could not figure it out, so I needed help. I would be grateful if someone could help me with this. Hello, this is my Java assignment. I could not figure it out,

so I needed help. I would be grateful if someone could help

Outputs and Inputs are here in the link.

https://ibb.co/bWnKwVn https://ibb.co/7QxNVBJ

In this assignment, you are going to write a Java program that reads in the data of some triangles from an input file, calculate the area of the triangles (valid triangles only), and write the results to an output file. Triangle Inequalities The triangle inequalities state that for any triangle, sum of the lengths of any two sides is always greater than the length of the third side (see the figure below). If any of the 3 inequalities is not satisfied, then the 3 side lengths cannot Triangle Area - Heron's Formula Given the 3 side lengths of a triangle, a,b, and c, the area of the triangle, A, can be calculated using the formula below: A=s(sa)(sb)(sc) where s is the half perimeter which equals to 2a+b+c. The Input File - The input file is a plain text file (filename: triangles.txt). - In each row of the input file, there are exactly 3 positive floating-point numbers (separated by whitespaces), which are the 3 side lengths of a (possible) triangle. - You cannot assume (or guess) the number of triangles in the input file. In other words, no matter how many (possible) triangles are stored in the input file, your program should correctly process all of them. - Please refer to the sample input files to better understand the input file format. - The output file is a plain text file (filename areas.txt). - For each (possible) triangle in the input file, your program should write its area to the output file. If the 3 side lengths in the input file cannot form a valid triangle, then your program should write "Invalid triangle" to the output file. - Each value should be a separate line in the output file. - Please refer to the sample output files to better understand the expected output file format. Other Development Notes - Please keep 2 decimal places for the values written to the output file. - Your program should use a loop to read the data in the input file. In each iteration, your program needs to read in the 3 side lengths of the next triangle from the input file (e.g., scanner. nextDouble ( )). - After reading in a triangle, your program should first check whether it is a valid triangle (triangle inequalities applied here). If it is valid, then calculate its area (Heron's formula applied here) and write it to the output file; if it is invalid, then write "Invalid triangle" to the output file. - Please review the lecture sample code, "rectangle area", which could be a great help for you to complete this assignment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!