Question: EE101 Task. 1. Implement a C++ class named Pendulum to represent a simple pendulum. 2. The class should have private member variables for the

EE101 Task. 1. Implement a C++ class named Pendulum to represent a

EE101 Task. 1. Implement a C++ class named Pendulum to represent a simple pendulum. 2. The class should have private member variables for the length of the pendulum (length) and the acceleration due to gravity (gravity). 3. Provide a constructor to initialize these variables. 4. Implement a member function calculate Period within the Pendulum class to calculate and return the period of the pendulum using the formula: T=2rt sqrt(length/gravity). 5. Implement a member function displayInfo to display information about the pendulum, including its length, gravity, and calculated period. 6. In the main function, create an instance of the Pendulum class with a length of 1.5 meters and gravity of 9.8 m/s. 7. Call the displayInfo function to print the information about the pendulum.

Step by Step Solution

3.36 Rating (143 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include iostream include cmath class Pendulum private double length Length of the pendulum double gr... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!