given Shape. neter will be a char containing the first letter of the shape's name, second and third parameters will be doubl e(i.e. radiuses of an ellipse or base and height lengths of a rectangle or triangle). The function should return the calling the function, your program should print out the area of the given shape as a double value. : For the area of ellipse, assume pi = 3.14. :shapeName van ONLY be 'E', T', or 'R', meaning ellipse, rectangle and triangle respectively. T: a h

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a program that calculates the area of a 2D geometric shape. The program will read three values: first one is the shape's name (shapeName) as
a char, second and third values are the dimensions of the shape (dimensionA, dimensionB) as two doubles.
Then, your program MUST use a function named "getArea" to calculate the area of the given shape. The function will take 3 parameters, first
parameter will be a char containing the first letter of the shape's name, second and third parameters will be doubles containing dimensions of the
shape (i.e. radiuses of an ellipse or base and height lengths of a rectangle or triangle). The function should return the area of the shape as a double.
After calling the function, your program should print out the area of the given shape as a double value.
NOTE: For the area of ellipse, assume pi = 3.14.
NOTE: shapeName van ONLY be 'E', T', or 'R', meaning ellipse, rectangle and triangle respectively.
HINT:
a
h
b
Area - (b*h)2
Area = b*h
Area = A xa×b
Input
E 5.3 4.8
5.2 8.4
E 1.2 4.56
T 45.12 0.44
R 4.7 7.2
Output
79.8816
21.84
17.1821
9.9264
33.84
Transcribed Image Text:Write a program that calculates the area of a 2D geometric shape. The program will read three values: first one is the shape's name (shapeName) as a char, second and third values are the dimensions of the shape (dimensionA, dimensionB) as two doubles. Then, your program MUST use a function named "getArea" to calculate the area of the given shape. The function will take 3 parameters, first parameter will be a char containing the first letter of the shape's name, second and third parameters will be doubles containing dimensions of the shape (i.e. radiuses of an ellipse or base and height lengths of a rectangle or triangle). The function should return the area of the shape as a double. After calling the function, your program should print out the area of the given shape as a double value. NOTE: For the area of ellipse, assume pi = 3.14. NOTE: shapeName van ONLY be 'E', T', or 'R', meaning ellipse, rectangle and triangle respectively. HINT: a h b Area - (b*h)2 Area = b*h Area = A xa×b Input E 5.3 4.8 5.2 8.4 E 1.2 4.56 T 45.12 0.44 R 4.7 7.2 Output 79.8816 21.84 17.1821 9.9264 33.84
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY