when a particular rubber ball is dropped form a given height (in metere) its imp
ID: 3830218 • Letter: W
Question
when a particular rubber ball is dropped form a given height (in metere) its impact speed (in meters /second when it hits the ground is given by this formula speed=2gh
where g is the acceleration caused by gravity and h is the height.the ball then rebounds to 2/3 the height from which it last fell write test and run a c++ Program that calculation and display the impact speed of the first three bounces and the rebound height of each bounce.test your program by using an intial height of 2.0 meters
run the programs twice and compare the results for dropping the ball on earthe (g=9.81 m/s 2) and the moon (g=1.67 m/s 2)
Explanation / Answer
Below is your code. I have added the comments to help you understand it. I have added the code for running for earth and moon in single code only. You can modify this according to your need.
#include<iostream>
using namespace std;
int main() {
double gOfEarth = 9.81; //Gravity of Earth
double gOfMoon = 1.67;//Gravity of Moon
double iHeight = 2.0; // Initial Height
double iSpeed; //Impact Speed
cout<<"For Earth:"<<endl;
for(int i =0;i<3;i++) {
cout<<"For Bound #"<<(i+1)<<":"<<endl;
iSpeed = 2*gOfEarth*iHeight; // Impact speed claculation
cout<<"Rebound Height:"<<iHeight<<" meters"<<endl;
cout<<"Impact speed:"<<iSpeed<<" m/sec"<<endl;
cout<<endl;
iHeight = iHeight*(2.0/3.0);
}
iHeight = 2.0; // again starting from height 2
cout<<endl;
cout<<"For Moon:"<<endl;
for(int i =0;i<3;i++) {
cout<<"For Bound #"<<(i+1)<<":"<<endl;
iSpeed = 2*gOfMoon*iHeight;// Impact speed claculation
cout<<"Rebound Height:"<<iHeight<<" meters"<<endl;
cout<<"Impact speed:"<<iSpeed<<" m/sec"<<endl;
cout<<endl;
iHeight = iHeight*(2.0/3.0);
}
return 0;
}
Sample Run: -
For Earth:
For Bound #1:
Rebound Height:2 meters
Impact speed:39.24 m/sec
For Bound #2:
Rebound Height:1.33333 meters
Impact speed:26.16 m/sec
For Bound #3:
Rebound Height:0.888889 meters
Impact speed:17.44 m/sec
For Moon:
For Bound #1:
Rebound Height:2 meters
Impact speed:6.68 m/sec
For Bound #2:
Rebound Height:1.33333 meters
Impact speed:4.45333 m/sec
For Bound #3:
Rebound Height:0.888889 meters
Impact speed:2.96889 m/sec
--------------------------------
Process exited after 0.1381 seconds with return value 0
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.