Computers and Technology
Computers and Technology, 09.12.2021 20:00, mashejaj

Design, implement and test a Java class that processes a series of triangles. As in that assignment, you will read in the three sides of the triangle, check the input for errors (and handle them if found), classify the triangle and compute its area. For this assignment, triangle data will be read from an input file and the program's output will be written to another file. The output file will also include a summary of the data processed. You must use at least one dialog box in this program. The data for each triangle will be on a separate line of the input file, with the input data echoed and the results referred to by the line number (see example).

Some things to note:

All input data lines must be processed.
A new line with triangle data always starts with the '#' marker.
If an error is encountered, it must be handled and the program will continue.
Extraneous data must be discarded. This is data that appears after the first three triangle sides are found, but before a new triangle marker is found.
If the end of file (EOF) is found, a message should be printed out
There shall be no unhandled file related exceptions and an end-of-file exception must be avoided.
On initialization, the program will prompt the user for both an input and an output file. If a non-existent input file is specified, the appropriate exception must be handled, resulting in an error message. For the exception case, re-prompt the user for the correct input file [Extra credit if you implement a JFileChooser type dialog box]. Once the I/O file is specified, the program will read in and process all the entries in the file. The output of the program will be written to the specified output file and echoed to the console.

The program will evaluate each line and determine the validity of the triangle. If valid, the program will output summary line for the triangle calculation. If invalid, the program will output a description of the error found in the entry. Your program must be robust and handle situations where all the triangle inputs are not proper and/or present.

Once all the entries are processed, a summary will be generated providing the following information:

Pathname of the input file
Number of lines processed
Number of valid triangles
Number of invalid triangles
The main features you will be adding are:

Multiple methods
Exception handing
File I/O
Dialog box
Sample file input:

# 3 4 5

# 5 5 5

# 5 5 7 XXX

# -3 10 10 15

# 0 0 0

# 3 4.1 5

# 3 x 4

# 5 4 3 6 YYY ZZZ

# 1 1 10

# 15 16 22

# 3 4

Corresponding file output:

1: 3, 4, 5: The triangle is a right triangle,

The area of this triangle is 6.00

2: 5, 5, 5: The triangle is equilateral,

The area of this triangle is 10.83

3: 5, 5, 7: The triangle is isosceles,

The area of this triangle is 12.50

Item discarded: XXX

Error - At least one of your sides is an invalid integer value

Item discarded: 15

Error - At least one of your sides is an invalid integer value

Error - At least one of your sides is not an integer

Error - At least one of your sides is not an integer

Error - Sides not in ascending order

Item discarded: 6

Item discarded: YYY

Item discarded: ZZZ

Error - Sides do not form a valid triangle

4: 15, 16, 22: This triangle is not distinctive,

The area of this triangle is 120.00

EOF found

File Path: E:\Java\Assign-05\pa5-test-01.txt
Summary Report

Total entries processed = 10

Number of valid entries = 4

Number of invalid entries = 6

Percentage of valid entries = 40.00%

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, soccerhannah290
Show that there is a language a ⚆ {0, 1} â— with the following properties: 1. for all x â a, |x| ≤ 5. 2. no dfa with fewer than 9 states recognizes a. hint: you don’t have to define a explicitly; just show that it has to exist. count the number of languages satisfying (1) and the number of dfas satisfying (2), and argue that there aren’t enough dfas to recognize all those languages. to count the number of languages satisfying (1), think about writing down all the strings of length at most 5, and then to define such a language, you have to make a binary decision for each string about whether to include it in the language or not. how many ways are there to make these choices? to count the number of dfas satisfying (2), consider that a dfa behaves identically even if you rename all the states, so you can assume without loss of generality that any dfa with k states has the state set {q1, q2, . . , qk}. now think about how to count how many ways there are to choose the other four parts of the dfa.
Answers: 3
image
Computers and Technology, 22.06.2019 10:30, darrengresham999
Choose the best explanation for the following statement communication is symbolic
Answers: 3
image
Computers and Technology, 22.06.2019 10:40, pbarbee3034
Nims is applicable to all stakeholders with incident related responsibilities. true or false
Answers: 1
image
Computers and Technology, 22.06.2019 10:50, christinavelez26
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata. mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata. mat g(s) = a1/(s + a2)
Answers: 1
Do you know the correct answer?
Design, implement and test a Java class that processes a series of triangles. As in that assignment,...

Questions in other subjects:

Konu
Arts, 19.05.2021 05:10