C++ help... 2 void functions must be used.. also the exponents must appear. Plea
ID: 3681084 • Letter: C
Question
C++ help... 2 void functions must be used.. also the exponents must appear. Please validate as it says no negative launch velocitites. Sample output below. include comments.
SAMPLE OUTPUT:
Enter launch velocity in mph =>7
Jumper will return
Another input?, press 1=>1
Enter launch velocity in mph =>3400
Jumper would return if the mass was at least 1.99675e+22
Another input?, press 1=>1
Enter launch velocity in mph =>540
Jumper will return
Another input?, press 1=>2
The average person can jump off the ground with a launch velocity of 7 mph without fear of leaving the planet. However, if an astronaut jumps with this launch velocity while standing on Halley's Comet, will the astronaut ever come back down? Create a program that allows the user to input a launch velocity (in mph) from the surface of Halley's Comet and determine whether a jumper will return to the surface. lf not, the program should calculate how much more massive the comet must be in order to return the jumper to the surface. Allow the user to continue input as long as he/she wishes no negative launch velocities allowed). Exponential form is acceptable. Use at least two (2) void functions. Escape velocity is SQRT (2 G* M R) use cmath for sqrt G gravitational constant 6.67 10 11 N melk M mass of of Halley's Comet 1.3 1022 kg R Halley's Comet radius 1.153 106 m Hint: The following constants can be used in your program const double G 6.67E-11 const double MASS 1.3E22 const double RADIUS F 1.153E6Explanation / Answer
Please find below the code for the requirement provided in the Question. Happy Holidays.!
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
double escVel,launchVel;
const double G= 6.67E-11;
const double MASS= 1.3E22;
const double RADIUS= 1.153E6;
//Function to calculate Escape Velocity of Halley's Comet
void CalculateEscpaeVelcoity()
{
escVel= sqrt(2*G*MASS/RADIUS);
cout<<"Escape Velocity of Haley's Comet is: "<<escVel<<endl;
}
//Function to calculate the minimum Mass for the Jumper to return to Halley's Comet
void CalculateMass(double lv, double ev) //lv:Launch Velocity, ev: Escape Velocity
{
double mass;
if(lv>ev)
{
mass= (lv*lv*RADIUS)/(2*G); // for Jumper to return, the comet's mass must abe able to confron the Jumper's Launch Velocity
cout<<"Jumper would return if the mass was at least: " <<mass<<endl;
}
else
{
cout<<"Jumper Will Return. "<<endl;
}
}
int main() {
char ch;
do{
cout<<"Please enter the Launch Velocity of Jumper: "<<endl;
cin>>launchVel;
cout<<"Jumper's Launch Velocity:"<<launchVel<<endl;
CalculateEscpaeVelcoity();
CalculateMass(launchVel, escVel);
cout<<"Do you wish to Continue(Y/N)?"<<endl;
ch=getchar();
}while(ch!='N' or ch!='n');
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.