Programming Assignment #5: Structs and Recursive Functions
Due on July 22nd, 11:59pm
Write one project for each of the three problems below in a Visual Studio solution and submit using OSBLE+ plugin. Don’t forget to use a comment box to write your name, date and assignment number. Use comments freely to explain what your code does. Follow the programming style guidelines discussed in class and the pdf posted on OBSLE+. The style will be graded based on the guidelines.
Problem 1: Fractions
We want to write a library for fractions (an Abstract Data Type). You are asked to provide a structured type to represent a fraction; it should contain two integer numbers, one for numerator and the other for denominator. You are also asked to write functions scanFraction, printFraction, addFraction, reduceFraction and multiFraction.
scanFraction and printFraction are for reading and printing a fractional number interactively. Do not worry about the format; it will suffice if you ask for two integer numbers and print two integer number.
addFraction accepts two fractions, computes their addition and returns it to the caller function.
multFraction accepts two fractions, computes their multiplication and returns the result to the caller function.
reduceFraction accepts one fraction, reduces it and returns the reduced fraction to the caller function. (you can use the GCD function from PA2, computation of the GCD won’t be graded here).
In your main function initialize two fractions 3/4 and -2/5. Compute their addition, multiplication and reduction and print the results.
Problem 2: Palindrome
Solve question 2 from chapter 9 of your textbook. The question is shown below:
Problem 3:
Solve problem 1 from chapter 10 of your textbook. The problem is shown below.
Problem 4: The Maze
Solve question 5 from chapter 9 of your textbook. The question reads:
Grading
Problem 1 is worth 25 points. 5 points for defining the struct itself, 5 points for print and scan functions together, 5 points for each one of the other functions.
Problem 2 is worth 20 points.
Problem 3 is worth 20 points. 10 point for defining the three structs and 10 points for the functions.
Problem 4 is worth 25 points.
Following a proper programming style is worth 10 points.