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
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
Related questions
Question
do not use java and be clear please .... your answers not all right
so, please be clear in your answer
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning