Convert a float to a fraction

Project #1

Convert and display a float number as a fraction.

Limit the input to positive numbers.

  1. ask the user to enter a positive float (number)
    • what to do with negative numbers or integers?
  2. convert the float to a fraction
    • for example: 0.2500 → 25/100
    • for example: 0.3 → 3/10
    • for example: 321.45 → 321 45/100
    • what if it does not break down into neat integers?
    • how precise does the results have to be?
    • can the user select the precision?
  3. display the original input and the resulting fraction (and the precision?)
  4. loop

How to exit the program?

Project #2

Modify the program to accept positive and negative numbers.

Links

How to convert a decimal number into fraction?