[50pts] Part 1: Death Traps

Write a program with source file named part1.cpp that plays a simple game.

The user/player enters the name of a file containing a "board" for the game (we provide board files boardX.txt, boardY.txt, and boardZ.txt ). The board is a rectangle representing the playing area. In between the @'s are width spaces. The .'s are safe spots, the X's are death traps.

width = 10
@X.........@
@......X...@
@....X....X@
@..X.......@
@........X.@
@.....X....@
file boardZ.txt
The player chooses a column number from 1 to width, and the game marches the player from the top of the board at that column position down until he either dies in a death trap, or makes it through safely. If the player dies, the game reports what step he died at: step 1 is the first row, step two the second, and so on. Otherwise it reports that the player survived.

If the file named by the user does not exist, print the message "File not found!" and exit. If the user enters a column number outside the range 1..width, print the message "Invalid position!" and exit.

~/$ ./part1 
foo.txt
File not found!

~/$ ./part1 
boardZ.txt
Enter position between 1 and 10: 15
Invalid position!

~/$ ./part1 
boardZ.txt
Enter position between 1 and 10: 7
You died on step 2

~/$ ./part1 
boardZ.txt
Enter position between 1 and 10: 2
You survived!

~/$ ./part1 
boardY.txt
Enter position between 1 and 30: 22
You died on step 17

[50pts] Part 2: Fibonnaci Sequences

In mathematics the Fibonacci sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones.

Write a program with a source file name part2.cpp that prompts the user to enter the total amount of numbers in the Fibonacci series and displays the resulting series to the user. The program should run until 0 is entered to terminate.

Here is a sample run (user input in red):

~/$ ./part2
Enter total numbers in the Fibonacci series (0 to exit): 9
Result: 0 1 1 2 3 5 8 13 21
Enter total numbers in the Fibonacci series (0 to exit): 11
Result: 0 1 1 2 3 5 8 13 21 34 55
Enter total numbers in the Fibonacci series (0 to exit): 15
Result: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
Enter total numbers in the Fibonacci series (0 to exit): 0
Program terminated.

Submit

~/bin/submit -c=IC210 -p=lab05 part1.cpp part2.cpp