Each Product's Share of Revenue
The board pack at Riverbend Supply carries a one-page breakdown of where the month's revenue came from. Each product line's takings are listed, and beside every one the board wants its share of the month expressed as a percentage. Dollar figures alone are hard to read across months of different sizes; a share tells the board how much a line mattered whether the month was a big one or a small one.
Task: Print each product line's share of the month's total revenue, as a percentage.
Input
The first line holds a single integer n, the number of product lines. Each of the next n lines holds one line's takings in dollars, which may carry decimals. The month's total is always above zero.
Output
One line holding n percentages, in the input order, separated by single spaces, each with one digit after the decimal point. A line worth a tenth of the month prints as 10.0, not as 0.1.
Example:
Input:
3
100
300
600
Output:
10.0 30.0 60.0
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