|
|
 |
|
|
|
|
function to compute the amount of interest. Your program should prompt the user appropriately, label output values, and have good style. |
|
|
|
|
|
|
|
|
2. Euclid's algorithm is a method for finding the greatest common divisor (GCD) of two positive integers. It states that, for any two positive integers M and N such that M<N, the GCD is calculated as follows: |
|
|
|
 |
|
|
|
|
a. Divide N by M. |
|
|
|
 |
|
|
|
|
b. If the remainder R = 0, then the GCD = M. |
|
|
|
 |
|
|
|
|
c. If R > 0, then M becomes N, and R becomes M, and repeat step (a) until R = 0. |
|
|
|
 |
|
|
|
|
Write a program that uses a value-returning function to find the GCD of two numbers. The main function reads pairs of numbers from a file stream named dataFile. For each pair read in, the two numbers and the GCD should be labeled properly and written to a file stream named gcdList. |
|
|
|
|
|
|
|
|
3. The distance to the landing point of a projectile, launched at an angle angle (in radians) with an initial velocity of velocity (in feet per second), ignoring air resistance, is given by the formula |
|
|
|
 |
|
|
|
|
Write a C++ program that implements a game in which the user first enters the distance to a target. The user then enters the angle and velocity for launching a projectile. If the projectile comes within a tenth of one percent of the distance to the target, the user wins the game. If the projectile doesn't come close enough, the user is told how far off the projectile is and is allowed to try again. If after five tries there isn't a winning input, then the user loses the game. |
|
|
|
 |
|
|
|
|
To simplify input for the user, your program should allow the angle to be input in degrees. The formula for converting degrees to radians is |
|
|
|
 |
|
|
|
|
Each of the formulas in this problem should be implemented as a C++ valuereturning function in your program. Your program should prompt the user for input appropriately, label the output values, and have proper programming style. |
|
|
|
|
|
|
|
|
4. Write a program that computes the number of days between two dates. One way of doing this is to have the program compute the Julian day number for each of the dates and subtract one from the other. The Julian day number is the number of days that have elapsed since noon on January 1, 4713 B.C. The following algorithm may be used to calculate the Julian day number. |
|
|
|
 |
|
|
|
|
Given year (an integer, such as 1997), month (an integer from 1 through 12), and day (an integer from 1 through 31), if month is 1 or 2, then subtract 1 from year and add 12 to month. |
|
|
|
 |
|
|
|
|
If the date comes from the Gregorian calendar (later than October 15, 1582), then compute an intermediate result with the following formula (otherwise, let intRes1 equal 0): |
|
|
|
 |
|
|
|
|
Compute a second intermediate result with the formula |
|
|
|
|
|