#C13148. Fraction to Float Conversion

    ID: 42654 Type: Default 1000ms 256MiB

Fraction to Float Conversion

Fraction to Float Conversion

Your task is to implement a program that reads a string representing a mathematical fraction from standard input and outputs its floating-point representation to standard output. The fraction will be in the format numerator/denominator, where numerator and denominator are integers. If the input is not in the correct format, or if the numerator/denominator parts are not valid integers, or if the denominator is zero, your program should output an appropriate error message. The expected error messages are:

  • Denominator cannot be zero. - if the denominator is zero.
  • Invalid fraction format. It should be in the form "numerator/denominator" with integers. - for any other format error.

Note: Output the result exactly as described (for valid fractions, output the floating point result; for invalid fractions, output the error message).

inputFormat

The input consists of a single line from standard input containing the fraction string.

outputFormat

Output to standard output the floating-point value of the fraction if valid, or the corresponding error message if the fraction format is invalid or if the denominator is zero.

## sample
3/4
0.75