Exercise 1: Write a python program that reads from a text file whose name is provided by the user and including lines relating to the dimensions of three kinds of shapes: Circle, Triangle, Trapezoid (see figure below for a sample input file). For each shape compute and display its area: - Triangle area = base X height. - Circle area = radius². - Trapezoid area = (base 1 + base,)X height. %3D Your program should consider the following erroneous cases: • The file does not open/exist • The format of the data in the file is incorrect (e.g. shape name = 'Polygon"), the shape's dimensions are incorrect (e.g. negative value or number of values for a trapezoid not equal to 3: base,, base, and height, or), in which case RuntimeError exception should be raised and the processing should continue. Triangle: 50 48 Shape Area Circle: -10 Trapezoid: 10 12 70 Trapezoid: Triangle Circle 1200.00 9 32 >> invalid dimension Trapezoid Trapezoid 770.00 >> missing data. Sample input file Sample output

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

do not use java and be clear please .... your answers not all right 

so, please be clear in your answer 

Exercise 1:
Write a python program that reads from a text file whose name is provided by the user and
including lines relating to the dimensions of three kinds of shapes: Circle, Triangle, Trapezoid
(see figure below for a sample input file). For each shape compute and display its area:
- Triangle area = base X height.
- Circle area = n radius².
- Trapezoid area =; (base 1 + basez)X height.
Your program should consider the following erroneous cases:
The file does not open/exist
• The format of the data in the file is incorrect (e.g. shape name = 'Polygon'), the shape's
dimensions are incorrect (e.g. negative value or number of values for a trapezoid not
equal to 3: base,, base, and height, or), in which case RuntimeError exception should
be raised and the processing should continue.
Shape
Area
Triangle:
Circle: -10
50
48
Triangle
Circle
Trapezoid: 10 12 70
1200.00
Trapezoid: 9
32
» invalid dimension
Trapezoid
Trapezoid
770.00
> missing data.
Sample input file
Sample output
Transcribed Image Text:Exercise 1: Write a python program that reads from a text file whose name is provided by the user and including lines relating to the dimensions of three kinds of shapes: Circle, Triangle, Trapezoid (see figure below for a sample input file). For each shape compute and display its area: - Triangle area = base X height. - Circle area = n radius². - Trapezoid area =; (base 1 + basez)X height. Your program should consider the following erroneous cases: The file does not open/exist • The format of the data in the file is incorrect (e.g. shape name = 'Polygon'), the shape's dimensions are incorrect (e.g. negative value or number of values for a trapezoid not equal to 3: base,, base, and height, or), in which case RuntimeError exception should be raised and the processing should continue. Shape Area Triangle: Circle: -10 50 48 Triangle Circle Trapezoid: 10 12 70 1200.00 Trapezoid: 9 32 » invalid dimension Trapezoid Trapezoid 770.00 > missing data. Sample input file Sample output
Expert Solution
steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Top down approach design
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
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