When a ball is thrown vertically upward from a reference location, it travels to a maximum height and then changes direction and experiences a fall.Ignoring the air resistance and a number of other tiny influences, the location of the ball (H) and its velocity (V) at time ( t) can be expressed by the following expressions:tgVoV)(2)2/()(tgtVoHHere Vois the initial upward velocity, gis the earth gravitational acceleration (9.81 m/s 2)and His measured upward from the reference location.Usingthe above expressions one can find the time(tm) it takes for the ball to reach its maximum height(Hm) and the time it takes for the ball to return to its reference location (tr) as listed below:gVotm/)2/(2gVoHmgVotr/2Write a program to:1.read the initial velocity of the ball from the keyboard and calculate tm, Hm, and trand then print their values with appropriate labels.Test the program for Vo= 100 m/sec.2.read a value for the time and calculate the corresponding velocity and the height of the ball and print their values with proper labels(use Vo= 100); test the program for t= 15 sec.

Respuesta :

Answer:

Explanation:

# include <iostream>

# include <iomanip>

using namespace std;

int main(){

               

               

               // PART 1

               const double GRAVITY = 9.81;

               double initial_velocity;

               

               cout<<"Enter initial velocity (in m/sec): "; cin >> initial_velocity;

               

               // calculate the time to reach the top

               double tm = initial_velocity/GRAVITY;

               

               // max height reached

               double Hm = (initial_velocity*initial_velocity)/(2*GRAVITY);

               

               // total elapsed time

               double tr = 2*tm;

               

               cout<<"Time taken to reach the top: " << tm << " sec(s)." << endl;

               cout<<"Max height attained : " << Hm << " m(s)." << endl;

               cout<<"Time to return to reference location: " << tr <<" sec(s)."<< endl << endl;

               

               

               // Part 2

               double sec;

               cout<<"Enter the time (in sec): "; cin >> sec;

               

               double Vo = 100; // taking Vo as 100 as mentioned in the question

               

               

               double V = Vo - GRAVITY*sec ; // calculate the Velocity at time user entered

               double H = Vo*sec - (GRAVITY*sec*sec)/2; // height attained at that time

               

               cout<<"Velocity at time "<<sec<<" sec(s) will be: " << V <<" m/s." << endl;

               cout<<"Height attained will be " << H <<" m(s). "<< endl;

               

}

======================================================================