//Andrew Alspaugh CS1A Chapter 6. P 370. #6
//
/*********************************************************************
*Calculate Kinetic Energy
* ___________________________________________________________________
* This Program Calculates the Kinetic Energy of an object
* ___________________________________________________________________
* Input
* m Mass
* v Velocity
* Output
* KE Kinetic Energy
*********************************************************************/
#include <iostream>
using namespace std;
//Function Protoype KineticEnergy
double KineticEnergy (double m, double v);
int main()
{
//DATA DICTIONARY
//Inputs
double m; //INPUT MASS KILOGRAMS
double v; //INPUT VELOCITY METERS PER SECOND
//Outputs
double KE; //OUTPUT KINETIC ENERGY
//INPUT
//Input Mass
cout << "Enter Mass in Kilograms: " << endl;
cin >> m;
while (m <= 0)
{
cout << "Enter Mass greater than 0" << endl;
cin >> m;
}
cout << "Mass is: " << m << endl << endl;
//Input Velocity
cout << "Enter Velocity in Meters/Second: " << endl;
cin >> v;
while (v <= 0)
{
cout << "Enter Velocity greater than 0" << endl;
cin >> v;
}
cout << "Velocity is: " << v << endl << endl;
//PROCESS
KE = KineticEnergy(m, v);
//OUTPUT
cout << "Kinetic Energy is: " << KE << endl;
return 0;
}
// KineticEnergy () Definition
double KineticEnergy(double m, double v)
{
return 0.5*m*(v*v);
}