Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In my CS class my professor asks us to rewrite the following BASIC game to C++.

ID: 3760377 • Letter: I

Question

In my CS class my professor asks us to rewrite the following BASIC game to C++.

**************The following link is the original instructions and sample run:

http://www.atariarchives.org/basicgames/showpage.php?page=106

**************The following is the BASIC code of the game:

**************This is what I got so far in C++.

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;


int main() {
  
  
  
cout << "LUNAR"<< endl;
cout << "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"<< endl;
cout << "THIS IS A COMPUTER SIMULATION OF AN APOLLO LUNAR LANDING CAPSULE."<< endl;
cout << "THE ON-BOARD COMPUTER HAS FAILED (IT WAS MADE BY XEROX) SO YOU HAVE TO LAND THE CAPSULE MANUALLY."<< endl;
cout << "SET BURN RATE OF RETRO ROCKETS TO ANY VALUE BETWEEN 0 (FREE FALL) AND 200 (MAXIMUM BURN) POUNDS PER SECOND."<< endl;
cout << "CAPSULE WEIGHT 33,000 LBS; FUEL WEIGHT 16,500 LBS."<< endl;
cout << "GOOD LUCK"<< endl;
  
float L = 0; //seconds
  
cout << "SEC MI + FT MPH LB FUEL BURN RATE" << endl;
int A = 120; //altitude
float V = 1; //*3600 to get mph, velocity
float M = 33000; //capsule mass
float N = 16500; //mass of empty capsule
float G = 1E-03; //gravity
float Z = 1.8; //unknown
float S;
float K; ///burn rate
float Q;
float J;
float I;
float W;
float T;
int redo;
cout << setw(2) << L << setw(7) << A << setw(4) << (5280*(A-A))<< setw(9) << (3600 * V) << setw(10) << (M-N) << endl;
   cout << "Enter Burn Rate" << endl;
cin >> K;
  

while ( cin >> K);
{ T=10;
  
if ((M-N) < 1E-03)
{
cout <<"FUEL OUT AT" << L << "SECONDS" << S << endl;
S = (-V + sqrt (V*V+2*A*G))/G;
}
  

else if (T < 1E-05);
{
cout << setw(2) << L << setw(7) << A << setw(4) << (5280*(A-A))<< setw(9) << (3600 * V) << setw(10) << (M-N) << endl;
}
//end of while loop
  
S = T;
if (M >= N+S*K);
{
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
}
  
if (I <= 0);
{
if (S < 5E-03);
{ W = (3600*V);
cout <<"ON MOON AT" << L << "SECONDS - IMPACT VELOCITY" << W << "MPH";
}
}
  
S=(M-N)/K;
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
   if (I <= 0);
{
if (S < 5E-03);
{ W = (3600*V);
cout <<"ON MOON AT" << L << "SECONDS - IMPACT VELOCITY" << W << "MPH";
}
}

   if (V <= 0);
   { L = L+S; T = T-S; M = S*K; A = I; V = J;
   }
   if ((M-N) < 1E-03)
{
cout <<"FUEL OUT AT" << L << "SECONDS" << S << endl;
S = (-V + sqrt (V*V+2*A*G))/G;
}
  
if (J < 0);
{ W=(1-M*G/(Z*K))/2; S=M*V/(Z*K*(W+sqrt(W*W+V/Z)))+.05;
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
   }
  
   V = V+G*S; L = L+S;
  
if (W <=1.2);
{cout << "PERFECT LANDING!" << endl;
cout << "TRY AGAIN (Y/N)??" << endl;
cin >> redo;
}
   if (W <= 10);
   {cout << "GOOD LANDING (COULD BE BETTER)" << endl;
   cout << "TRY AGAIN (Y/N)??" << endl;
   cin >> redo;
   }
   if (W > 60);
   {cout << "SORRY THERE ARE NO SURVIVORS. YOU BLOW IT!" << endl;
   cout << "IN FACT, YOU BLASTED A NEW LUNAR CRATER" << W*0.227 << "FEET DEEP!" << endl;
   cout << "TRY AGAIN (Y/N)??" << endl;
   cin >> redo;
   }
}
}

Explanation / Answer

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;


int main() {
  
  
  
cout << "LUNAR"<< endl;
cout << "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"<< endl;
cout << "THIS IS A COMPUTER SIMULATION OF AN APOLLO LUNAR LANDING CAPSULE."<< endl;
cout << "THE ON-BOARD COMPUTER HAS FAILED (IT WAS MADE BY XEROX) SO YOU HAVE TO LAND THE CAPSULE MANUALLY."<< endl;
cout << "SET BURN RATE OF RETRO ROCKETS TO ANY VALUE BETWEEN 0 (FREE FALL) AND 200 (MAXIMUM BURN) POUNDS PER SECOND."<< endl;
cout << "CAPSULE WEIGHT 33,000 LBS; FUEL WEIGHT 16,500 LBS."<< endl;
cout << "GOOD LUCK"<< endl;
  
float L = 0; //seconds
  
cout << "SEC MI + FT MPH LB FUEL BURN RATE" << endl;
int A = 120; //altitude
float V = 1; //*3600 to get mph, velocity
float M = 33000; //capsule mass
float N = 16500; //mass of empty capsule
float G = 1E-03; //gravity
float Z = 1.8; //unknown
float S;
float K; ///burn rate
float Q;
float J;
float I;
float W;
float T;
int redo;
cout << setw(2) << L << setw(7) << A << setw(4) << (5280*(A-A))<< setw(9) << (3600 * V) << setw(10) << (M-N) << endl;
   cout << "Enter Burn Rate" << endl;
cin >> K;
  

while ( cin >> K);
{ T=10;
  
if ((M-N) < 1E-03)
{
cout <<"FUEL OUT AT" << L << "SECONDS" << S << endl;
S = (-V + sqrt (V*V+2*A*G))/G;
}
  

else if (T < 1E-05);
{
cout << setw(2) << L << setw(7) << A << setw(4) << (5280*(A-A))<< setw(9) << (3600 * V) << setw(10) << (M-N) << endl;
}
//end of while loop
  
S = T;
if (M >= N+S*K);
{
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
}
  
if (I <= 0);
{
if (S < 5E-03);
{ W = (3600*V);
cout <<"ON MOON AT" << L << "SECONDS - IMPACT VELOCITY" << W << "MPH";
}
}
  
S=(M-N)/K;
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
   if (I <= 0);
{
if (S < 5E-03);
{ W = (3600*V);
cout <<"ON MOON AT" << L << "SECONDS - IMPACT VELOCITY" << W << "MPH";
}
}

   if (V <= 0);
   { L = L+S; T = T-S; M = S*K; A = I; V = J;
   }
   if ((M-N) < 1E-03)
{
cout <<"FUEL OUT AT" << L << "SECONDS" << S << endl;
S = (-V + sqrt (V*V+2*A*G))/G;
}
  
if (J < 0);
{ W=(1-M*G/(Z*K))/2; S=M*V/(Z*K*(W+sqrt(W*W+V/Z)))+.05;
Q = ((S * K)/ M);
J = V + (G*S) + Z * (-Q-((Q*Q)/2))- ((Q*Q*Q)/3)-((Q*Q*Q*Q)/4)-((Q*Q*Q*Q*Q)/5);
I = A - (G * S * S / 2)- (V * S) + (Z * S* (Q/2+Q*Q/6+Q*Q*Q/12+Q*Q*Q*Q/20+Q*Q*Q*Q*Q/30));
   }
  
   V = V+G*S; L = L+S;
  
if (W <=1.2);
{cout << "PERFECT LANDING!" << endl;
cout << "TRY AGAIN (Y/N)??" << endl;
cin >> redo;
}
   if (W <= 10);
   {cout << "GOOD LANDING (COULD BE BETTER)" << endl;
   cout << "TRY AGAIN (Y/N)??" << endl;
   cin >> redo;
   }
   if (W > 60);
   {cout << "SORRY THERE ARE NO SURVIVORS. YOU BLOW IT!" << endl;
   cout << "IN FACT, YOU BLASTED A NEW LUNAR CRATER" << W*0.227 << "FEET DEEP!" << endl;
   cout << "TRY AGAIN (Y/N)??" << endl;
   cin >> redo;
   }
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote