You are on page 1of 6

Projectile Kinematics equation calculator

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int choice;
double a,s,vf,vi;
char x;
do
{
cout<<"PROJECTILE KINEMATICS EQUATION
CALCULATOR"<<endl;
cout<<"2as=vf2-vi2"<<endl;
cout<<"enter 1 if you want to find
acceleration"<<endl;
cout<<"enter 2 if you want distance"<<endl;
cout<<"enter 3 if you want final
velocity"<<endl;
cout<<"enter 4 if you want initial
velocity"<<endl;
cout<<"Enter your Choice=";
cin>>choice;
if(choice==1)
{
cout<<"enter Distance s=";
cin>>s;
cout<<"enter final velocity vf=";
cin>>vf;
cout<<"enter initial velocity vi=";
cin>>vi;
a=(pow(vf,2)-pow(vi,2)/2*s);//
pow(num,power) for power like 2powe 2
cout<<"acceleration is"<<a;
}
if(choice==2)
{
cout<<"enter acceleration a=";
cin>>a;
cout<<"enter final velocity vf=";
cin>>vf;
cout<<"enter initial velocity vi=";
cin>>vi;
s=((pow(vf,2)-pow(vi,2))/2*a);
cout<<"distance is"<<s;
}
if(choice==3)
{
cout<<"enter acceleration a=";
cin>>a;
cout<<"enter distance s=";
cin>>s;
cout<<"enter initial velocity vi=";
cin>>vi;
vf=sqrt(2*a*s+pow(vi,2));//sqrt() for
square root
cout<<"final velocity is"<<vf;
}
if(choice==4)
{
cout<<"enter acceleration a=";
cin>>a;
cout<<"enter distance s=";
cin>>s;
cout<<"enter final velocity vf=";
cin>>vf;
vi=sqrt(-2*a*s+pow(vf,2));//sqrt() for
square root
cout<<"initial velocity is"<<vi;
}
cout<<endl;
cout<<"do you want to continue"<<endl;
cout<<"if yes press Y/y and if you want to
end press N/n"<<endl;
cin>>x;
}
while(x=='y'|| x=='Y');
}

You might also like