### Design for 115 Program 3, Spring 2001

Phase I
```1. output an explanation of the game to the user

2. repeat 5 times with a counter i or until the user wins
3. 	output "Trial #"  i
4.	input user's velocity and angle
6.	calculate distance travelled
7.	output distance
8.	calculate error to target of 500 feet
9.	if error in range of 0.1 percent of 500
report win
else if error is positive
report "not far enough"
else
report "too far"
10.	increment counter i

11. if user didn't win, report loss

2.1  make the loop a do/while because need to play at least
once to see if user has won the game
do {steps 3-10}while (ctr < 5 && fabs(error) > 0.1 percent of 500);

5.1   angle = convertdtor(angle);
8.1 	error = 500 - distance
```
Phase II
```Random number used for target

Add these steps to the beginning of the main function, before the loop starts

1. ask the user for a seed
2. call srand with it
3. call rand() to get a number for the target
4. calculate the range for error allowed and report it to the user

4.1  double delta = target * 0.001;
4.2  cout << "You have to get within " << delta << " feet" << endl;

```

Phase III

Rename the main function from the previous phase to bool game () and add in a return statement at the end of the function, which returns true or false depending on whether the user won the game or not.

```	if (fabs(error) > delta )
{ cout << "you lose!!" << endl;
return false;
}
else
return true;

```

```1. use counters for number of games and for number of wins
2. initialize them to zero
3. ask the user if they want to play a game
4. get response

5. while response is yes
6. 	increment game counter
7. 	call function that plays a game
8. 	if the user wins
increment win counter
9. 	ask the user if they want to play a game
10. 	get response

11. report wins and losses
```