Saturday, 23 Oct 2021

# Program to calculate Kinetic Energy and Potential Energy

Program to calculate Kinetic Energy and Potential EnergyGiven three integers M, H, and V representing the mass, velocity, and height of an object respectively the task is to calculate its Kinetic Energy as well as its Potential Energy,Note: The value of acceleration due to gravity (g) is 9.8 and ignore units.   Examples:Input: M = 25, H = 10, V = 15Output:Kinetic Energy = 2812.5Potential Energy = 2450Explanation : The kinetic energy of the particle is 2812.5 and the potential energy is 2450.Input : M=5.5, H=23.5, V= 10.5Output :303.1881266.65Approach: The required values of Kinetic Energy and Potential Energy can be calculated using the following two formulas:Kinetic Energy = 0.5 * Mass ( M ) * Velocity ( V ) 2 Potential Energy = Mass ( M ) * Height ( H ) * Acceleration due to gravity ( g )Below is the implementation of the above approach:C++14  #include using namespace std;  float kineticEnergy(float M, float V){        float KineticEnergy;      KineticEnergy = 0.5 * M * V * V;      return KineticEnergy;}  float potentialEnergy(float M, float H){        float PotentialEnergy;      PotentialEnergy = M * 9.8 * H;      return PotentialEnergy;}  int main(){    float M = 5.5, H = 23.5, V = 10.5;      cout