Command Line Fractional calculator using Swift

How it works?

  • The command-line program will repeatedly prompt the user for input and display the result until user types “exit”.
  • Legal operators shall be *,  /,  +,  – (multiply, divide, add, subtract).
  • Operands and operators shall be separated by one or more spaces.
  • Mixed numbers will be represented by whole&numerator/denominator; for example, “3&1/4”, “-1&7/8”.
  • Improper fractions, whole numbers, and negative numbers are allowed as operands. 

Example runs (where ‘?’ represents the command prompt):
? 1/2 * 3&3/4
= 1&7/8 

? 2&3/8 + 9/8
= 3&1/2

? 1&3/4 – 2 = -1/4

How to run?

Download or Clone the project and you can run the fCalc target on My Mac destination and under console you can type inputs, and you can get the result or issues, if any. image

Where to get executable?

Open Build directory image

Enter inputs and hit enter to get results. Enter “exit” to quit

Screenshot 2023-09-11 at 8 13 29 AM


View Github