Problem C
Formatting
A floating point number is a rational number expressed as a
decimal. In other words, a number made up of digits and at most
one decimal point.
Write a program that, given a floating point number, formats it
such that it follows the following specifications:
-
Has a field width of 12
-
Has exactly 2 decimal digits of precision
-
Is right justified
Input
Input consists of one line containing one floating point
number $f$, with at most
$18$ digits after the
decimal point, where $0 \leq f
\leq 10^9$
Output
Output consists of a single line, the formatted floating point number. Note that your output must be exactly as described above. This means it must have the correct number of leading spaces and finally one newline character at the end of the number.
Sample Input 1 | Sample Output 1 |
---|---|
1234.56789 |
1234.57 |
Sample Input 2 | Sample Output 2 |
---|---|
3456 |
3456.00 |