Make a C++ program that will compute for the area of a Triangle, Square, Rectangle, Ellipse, and Circle using Class. The variable area is private and of type float. Encapsulation is a must. showArea() can be used to return the computed area value coming from the different methods for area computation. Create 5 objects named a1 to a5. Use one area method for each object and show its corresponding area. You can give any value for the dimensions.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 1CP
icon
Related questions
Question

Make a C++ program that will compute for the area of a Triangle, Square, Rectangle, Ellipse, and Circle using Class.

The variable area is private and of type float.

Encapsulation is a must.

showArea() can be used to return the computed area value coming from the different methods for area computation.

Create 5 objects named a1 to a5.

Use one area method for each object and show its corresponding area.

You can give any value for the dimensions.

No input is needed.

 

 

Output should be:

 

The area of the triangle is 6.00000.

The area of the square is 25.00000.

The area of the rectangle is 6.00000.

The area of the ellipse is 18.84956.

The area of the circle is 28.27433.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
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