#include<iostream>
#define g 9.087//define g
#define v0 0//define initial velocity
using namespace std;
void func(int time)
{
int t = 0;
double v = 0.0, s = 0.0;
//The equaions to calculate v and s
t = time;
s = v0*t + 0.5*g*t*t;
v = v0 + g*t;
//The output of data
cout << "*****************************************************************************" << endl;
cout << "WHEN THE TIME IS "<< t <<" SECONDS THE DISTANCE TRAVELED IS "<<s <<" METERS." << endl;
cout << "THE VELOCITY IS "<< v <<" METERS PER SECOND."<<endl;
}
int main()
{
//calling function to calculate the results and print them on the screen
func(1);
func(2);
func(4);
func(5);
func(10);
system("pause");
return 0;
}
回到主页
回到目录