In: Computer Science
COSC 1436 Programming Assignment :
Skill Practice Assignment 3
Your skill practice assignment this week will be programming challenge #6 on page 374 - Kinetic Energy
In it you are asked to write a programing that returns the amount of kinetic energy the object has. You will ask the user to enter values for mass and velocity. You will need to create a function named kinetic Energy that accepts an object's mass (in kilograms) and velocity (in meters per second) as arguments. The function will return the amount of kinetic energy that the object has. You will display the results to the user.
Read the programming assignment in the book. Make sure to do what the specification is asking you to do. All of what it is asking you to do. You probably want to use variables of type double, not int.
Solution:- First of all, we know the formula of Kinetic Energy, which is used to find the K.E. of an object with the help of its mass and velocity.
Kinetic Energy = 1/2(MV2)
NOTE **:- I'm using C++ Language for the Problem.
Code...
#include<iostream>
using namespace std;
// function for Kinetic Energy of Object
double kinetic_Energy(double mass, double velocity){
double KE = mass*(velocity*velocity)/2;
return KE;
}
int main(){
double mass,velocity,result;
cout<<"Enter The Mass Of Object (Should be in
Kg) : ";
cin>>mass;
cout<<"\nEnter The Velocity Of Object (Should be
in m/s) : ";
cin>>velocity;
cout<<"\nmass : "<<mass<<" Kg,
Velocity : "<<velocity<<" m/s";
result=kinetic_Energy(mass,velocity);
cout<<"\n\nKinetic Energy Of The Object is :
"<<result;
}