Lexington High School Mathematics Math Dept. Front Page  | Student Links  | Family Links 
Introduction to C++, Kevin Kelly Kelly Front Page  | C++ Course Guide | C++ Assignments | C++ Info

Assignment 6: Fraction converter

due Tuesday 2/12

Write a program that will convert a fraction (of two positive whole numbers) into a mixed number and into a decimal. Here is an example of what the user interaction should look like:

Enter the numerator: 7
Enter the denominator: 3

7/3 is equal to 2 1/3.
It also equals 2.33333.

Test values for your sample runs: Please run the program five times using the fractions 9/2, 77/9, 23456/100, 20/4, and 5/7.




Extensions

For 10 points: Make your program handle negative numbers correctly. (For example, -7/3 as a mixed number is -2 1/3.) Include enough additional test values to show that your program handles every combination of positives and negatives correctly.