You are provided with an input file ("Data.txt") containing a number of text lines. Each line contains a record of a supposed triangle. Each record has four attributes: record number, three sides values. The record number and the sides are separated by :' while the three attributes are separated by one space. Figure 1 shows a sample input file. You are asked to write a Python program that reads the content of the input file, checks whether the sides form a triangle or not. When the sides form a triangle, finds out its type ('Equilateral' or "Not Equilateral' then computes its perimeter (P) and its area (A). There will be three cases according sides values: > Equilateral triangle if all sides are cqual (S = Si = S2 = Si). Then compute the perimeter (P) and area (A) of triangle as follows: P= 35 ; A =s

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

please use spyder

In Math, an equilateral triangle is a triangle in which all three sides are equal.
You are provided with an input file ("Data.txt") containing a number of text lines. Each line
contains a record of a supposed triangle. Each record has four attributes: record number, three
sides values. The record number and the sides are separated by :' while the three attributes are
separated by one space. Figure 1 shows a sample input file.
You are asked to write a Python program that reads the content of the input file, checks whether
the sides form a triangle or not. When the sides form a triangle, finds out its type ("Equilateral' or
"Not Equilateral then computes its perimeter (P) and its area (A). There will be three cases
according sides values:
> Equilateral triangle if all sides are equal (S = Sı = S2 = S:). Then compute the
perimeter (P) and area (A) of triangle as follows:
v3
P= 35; A =-s?
- Not equilateral triangle if sides are not equal. Then compute the perimeter and area
of triangle as follows:
P = S, + S2 + S, ; A = P/2-(P/2-s.).(*/2- s2). (*/2– S»)
Not triangle if one side or more, is less than or equal zero. Then add record number in
a list of records not forming a triangle then read next record.
Your program should display for each triangle, the sides of the triangle, its perimeter and its area
as well as its type (Equilateral or Not equilateral). Your program should also display, as a comma
separated list, the numbers of records that are not a triangle. The figure 2 shows a sample output.
|1:4.5 5.5 6.555
2:0 4.56 2.9
3:6.982 7.53 8.4
Sidel
Side2
Side3
Perimeter Area
Туре
4.50
5.5e
6.55
16.55
12.23
Not Equilateral
Not Equilateral
Equilateral
Equilateral
4:2.5 2.5 2.5
6.98
2.50
7.53
2.se
8.40
2.5e
22.91
7.se
24.80
2.71
5:-3.0 5.678 5.01
6:6.0 6. 0 6.0
6.00
6.00
6.00
18.00
15.59
7:9.3 10.032 -6.0213
Records not a triangle: 2, 5, 7
Figure 1. Sample input file
Figure 2. Sample output
Transcribed Image Text:In Math, an equilateral triangle is a triangle in which all three sides are equal. You are provided with an input file ("Data.txt") containing a number of text lines. Each line contains a record of a supposed triangle. Each record has four attributes: record number, three sides values. The record number and the sides are separated by :' while the three attributes are separated by one space. Figure 1 shows a sample input file. You are asked to write a Python program that reads the content of the input file, checks whether the sides form a triangle or not. When the sides form a triangle, finds out its type ("Equilateral' or "Not Equilateral then computes its perimeter (P) and its area (A). There will be three cases according sides values: > Equilateral triangle if all sides are equal (S = Sı = S2 = S:). Then compute the perimeter (P) and area (A) of triangle as follows: v3 P= 35; A =-s? - Not equilateral triangle if sides are not equal. Then compute the perimeter and area of triangle as follows: P = S, + S2 + S, ; A = P/2-(P/2-s.).(*/2- s2). (*/2– S») Not triangle if one side or more, is less than or equal zero. Then add record number in a list of records not forming a triangle then read next record. Your program should display for each triangle, the sides of the triangle, its perimeter and its area as well as its type (Equilateral or Not equilateral). Your program should also display, as a comma separated list, the numbers of records that are not a triangle. The figure 2 shows a sample output. |1:4.5 5.5 6.555 2:0 4.56 2.9 3:6.982 7.53 8.4 Sidel Side2 Side3 Perimeter Area Туре 4.50 5.5e 6.55 16.55 12.23 Not Equilateral Not Equilateral Equilateral Equilateral 4:2.5 2.5 2.5 6.98 2.50 7.53 2.se 8.40 2.5e 22.91 7.se 24.80 2.71 5:-3.0 5.678 5.01 6:6.0 6. 0 6.0 6.00 6.00 6.00 18.00 15.59 7:9.3 10.032 -6.0213 Records not a triangle: 2, 5, 7 Figure 1. Sample input file Figure 2. Sample output
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Transmission media
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning