The Price String Problem
Larchfield Analytics scrapes competitor prices straight off web pages, so what arrives is text exactly as a shopper would read it: a currency symbol in front, commas breaking up the thousands, and a dot before the cents. The pricing report needs the total of those prices, and none of that punctuation means anything to arithmetic.
Task: Print the total of the scraped prices.
Input
The first line holds one integer n, how many prices follow. Each of the next n lines holds one price: a $ sign, then the amount, in which commas separate groups of thousands and a single dot separates the cents. Every price carries two digits of cents, and a price may have more than one comma in it.
Output
One line holding the total with exactly two digits after the decimal point.
Example:
Input:
3
$1,299.99
$45.50
$0.51
Output:
1346.00
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