Rounding a Report to Whole Dollars
Alderwood Supply prints a one-page ledger summary for its board, and the board wants whole dollars only — no cents anywhere on the page. Chopping the cents off is not allowed: a figure of 10.6 has to appear as 11, not 10. A figure that sits exactly halfway between two whole dollars is settled by a house rule — it goes to whichever of the two neighbouring whole dollars is an even number, so 10.5 becomes 10 and 11.5 becomes 12.
Task: Print every figure as its nearest whole dollar.
Input
The first line holds an integer n, the count of figures. Each of the next n lines holds one figure, written with a decimal point. A figure may be negative.
Output
One line holding the n whole-dollar figures, separated by single spaces, in the order they were read. Print each as a plain integer: no decimal point, no trailing .0.
Example:
Input:
3
10.4
10.5
10.6
Output:
10 10 11
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in