//Ryan Shahriyarpour   CS1A     Carl Argila CH6 HW  Q:6
//
/*****************************************************************************
 * 
 * Kinetic Energy
 * 
 *********************
 * 
 * This program calculates the kinetic energy of a moving object using the
 * function kineticEnergy. The \formula is:
 * KE = (1/2) * m * v^2
 * 
 * INPUT
 *  mass      - the object's mass in kilograms
 *  velocity  - the object's velocity in meters per second
 * 
 * OUTPUT    
 *  The object's kinetic energy in joules
 * 
 ****************************************************************************/
 
#include <iostream>
using namespace std;
 
// Function prototype
double kineticEnergy(double mass, double velocity);
 
int main()
{
    double mass;       // Mass in kilograms
    double velocity;   // Velocity in meters per second
 
    cout << "Enter the object's mass (kg): ";
    cin >> mass;
    cout << "Enter the object's velocity (m/s): ";
    cin >> velocity;
 
    cout << "The object's kinetic energy is "
         << kineticEnergy(mass, velocity) << " joules.\n";
 
    return 0;
}
 
// Accepts mass and velocity and returns the kinetic energy in joules
double kineticEnergy(double mass, double velocity)
{
    return 0.5 * mass * velocity * velocity;
}