Path length is 6548.85 feet
Time to impact is 7.82 seconds
After you have entered the slightly modified program and run it to get the answers, print out a page with your program on it. (You MUST do this printing using the Visual Studio programming environment, NOT a word processor.) Then, do one of the following, depending on the last digit of your Banner ID nunber. Deliberately make one of the following mistakes in your program and then try to compile again - choose the mistake whose number matches the last digit of your Banner ID number. You should get one or more error or warning messages. By hand, write the last digit of your Banner ID number, and the error/warning message(s) you get on the bottom or back of your printout; then hand it in.
0. Replace the 0 from the return
0; statement with "done".
1. Omit the semicolon from timeToImpact
= arcLength / SPEED;
2. In the declaration of arcLength,
double
arcLength;
omit the h in arcLength.
3. Omit the () after the word main.
4. Replace the << in cout
<< endl; with >>
5. Omit the // on the line //
Use the standard formula for length
6. Change the declaration, const
double HEIGHT = 956.25;
to const double HEIGHT;
7. Misspell log in messy = log((2.0
* HEIGHT + radical)/half);
as lg.
8. Misspell double in double
half; as doble.
9. Change // to /* in the comment //
Output the results
Do NOT save your program with the error
in it. Do NOT print out your program with the error in it. By hand, using
your best handwriting, write the error/warning message(s) on the printout
of the correct program. Be sure to look at the entire message window
to find all error/warning messages.
// *****************
// Project #1: Ballistics
// This program calculates the trajectory length of new type of
mortal shell.
// Given the distance to be covered, the maximum height of the
shell, and its
// average speed, the program calculates the path length and the
time it takes
// to get there. The method of calculation uses the standard
formula for the
// length of an arc of a parabola.
//
// Written by Jim Wolfe
// Due: 14 September 05
//
// Inputs: None; all needed values are specified as
constants
// Outputs: Length of path (in feet) and time to traverse
path (in seconds)
// ****************
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double HEIGHT = 956.25; // Maximum
height of shell (in feet)
const double DISTANCE = 6174.0; // Distance to
target (in feet)
const double SPEED = 837.0;
// Average speed of shell (in feet/sec)
int main ()
{
double half;
// Half the distance to the target
double messy;
// Complicated expression we need log of
double radical;
// Square root portion of the formula
double arcLength;
// Length of the arc/path (in feet)
double timeToImpact;
// Time to reach target (in seconds)
cout << fixed << showpoint
<<
setprecision(2); // Format results to have 2 decimal places
half = DISTANCE / 2.0; // Get half
the distance to target
// Use the standard formula for length
radical = sqrt (4.0 * HEIGHT * HEIGHT +
half * half);
messy = log ((2.0 * HEIGHT + radical)
/ half);
arcLength = radical + half * half * messy
/ (2.0 * HEIGHT);
timeToImpact = arcLength / SPEED;
// Output the results
cout << "Path length is " <<
arcLength << " feet" << endl;
cout << "Time to impact is " <<
timeToImpact << " seconds" << endl;
cout << endl;
return 0;
}