(Solved) : 75 Foot Tall Wall Target Located 150 Feet Past Target 50 Feet Wide Ignore Height Target A Q44144205 . . .
There is a 75 foot tall wall and the target is located 150 feetpast it. The target is 50 feet wide – we will ignore the height ofthe target and assume that anything that lands within the area ofits base would hit the target. The catapault always launches rocksat a 45 degree angle – to make life easy we will assume that theyare launched from a height of 0 feet. Your program should read in adistance the catapault is from the wall (in feet) and an initialvelocity for the rock it throws and report whether the shot: hitsthe wall, is too short, is too long, or hits the target. If theshot does not hit the wall, report how far it traveled in total. Inparticular, you will need the Parabolic Trajectory equation thatgives a height for the rock after it travels x feet and the Rangeequation. Your program is reading in u (initial velocity). Use thevalue 32.17405 for g and 3.1419265359 for Pl.
#include
using namespace std;
int main()
{
int testcase;
cout<<“Enter no of testcase “;
cin>>testcase;
while(testcase–)
{
int distance,velocity;
cout<<“Enter distance from wall: “;
cin>>distance;
cout<<“Enter velocity: “;
cin>>velocity;
double g=32.17405;
double pi=3.1419265359;
int dis_from_wall_to_target=distance+150;
intdis_from_wall_with_target=distance+150+50;
//d*(1-d*g/v*v)>height of wall then itcross the walll
doubleheight=distance*(1.0-((distance*g*1.0)/(velocity*velocity)));
if(height>75)
{
//travel_distance=(v*v)/g when ball cross the wall then totaltravelled distance by ball
doubletravel_distance=(velocity*velocity*1.0)/g;
if(travel_distance {
cout<<“Too short!n”;
}
elseif(travel_distance<=dis_from_wall_with_target)
{
cout<<“Hit!n”;
}
else
{
cout<<“Too far!n”;
}
cout<<“Rocktraveled “< }
else
{
cout<<“Hits thewall!n”;
}
}
return 0;
}
does the job without the variable pi! why do i need it ?
Please also provide with an alternative way of writing thiscode.
Expert Answer
Answer to There is a 75 foot tall wall and the target is located 150 feet past it. The target is 50 feet wide – we will ignore th…
OR