Seawolf

(attached file included)

#include <iostream> #include <iomanip> #include <fstream> #include <cmath> using namespace std; int attempts = 0; double computeDistance(double &Velocity , double &toRadians); // loop double toRadians(double Angle, const double PI = acos(-1.)); double TargetDistance; double Velocity; double Angle; double YourHit; double radians; double TargetRange; double HiTargetRange; double LoTargetRange; int main() { cout << "Program for The Granbde Pumpkin Shoot.\n\n"; cout << "Program by John M. Grow Cs-07-1.\n\n"; cout<<"Enter the Target Distance.\n"; cin >> TargetDistance; HiTargetRange = (TargetDistance + (TargetDistance * .001)); LoTargetRange = (TargetDistance - (TargetDistance * .001)); cout<<"\nYou only have 5 chances to get this right.\nSo think carefully before you enter you data.\n\n\n"; while (attempts < 5){ cout <<"\nEnter the velocity (speed) of the pumpkin: "; cin >> Velocity; cout <<"Now enter the angle of the cannon: "; cin >>Angle; attempts ++; double YourHit = computeDistance(Velocity , toRadians); // loop cout << YourHit; } // end of program results win try again lose if (YourHit <= HiTargetRange && YourHit >= LoTargetRange ){ cout <<"\n\n GOOD JOB........YOU WIN\n\n"; return 1; } else if (attempts >= 6){ cout <<"\a\n\n\aGAME OVER. INSERT ANOTHER QUARTER TO CONTINUE."; return 2; } } double computeDistance(double &Velocity , double toRadians ){ double YourHit; double speed; speed = pow(Velocity, 2); YourHit = (speed * sin(2*radians))/32.2; return YourHit; } double toRadian(double Angle, const double PI = acos(-1.)){ double radians; radians = (Angle*PI)/180; return radians; }