//********************************************************* // Projectile.cpp // // This program allows the user to play a game in which // (s)he tries to find the correct combination of initial // velocity and angle so that a projectile will travel a // given distance (entered by the user). // // D. Searls // Asbury College // Aug 2003 //********************************************************* #include #include using namespace std; const double PI = 3.14159265358979; const double G = 32.2; const double PERCENT_ERR = 1.0; // Error tolerance in percent double projectileDistance(double velocity, double angle); bool isCorrectDistance(double calculatedDist, double desiredDist); int main() { double desiredDist; double velocity; double angle; // in degrees double calcDist; char userResponse; int numTries; bool solutionFound; // Display the instructions cout << " HORIZONTAL DISTANCE TRAVELED BY A PROJECTILE\n\n"; cout << "In this game, you will enter the horizontal distance that a projectile\n"; cout << "should travel. You will then be given up to five chances to enter the\n"; cout << "correct combination of the initial velocity and the angle (above the\n"; cout << "horizontal) at which the projectile should be launched. If you get the\n"; cout << "correct combination within five tries then you win the game.\n\n"; cout << "Do you want to play (Y or N)? "; cin >> userResponse; while (toupper(userResponse) == 'Y') { // The code to play the game goes here cout << "Do you want to play again (Y or N)? "; cin >> userResponse; } cout << endl; return 0; } //--------------------------------------------------------- // projectileDistance // // In Parameters: velocity (ft/sec), angle (degrees) // // Returns: the horizontal distance traveled by a projectile. //--------------------------------------------------------- double projectileDistance(double velocity, double angle) { return 0.0; } //--------------------------------------------------------- // isCorrectDistance // // In Parameters: calculatedDist, desiredDist // // Returns: true if the calculatedDist is within PERCENT_ERR // of desiredDist. Otherwise, it returns false. //--------------------------------------------------------- bool isCorrectDistance(double calculatedDist, double desiredDist) { return true; }