HDU 4493 tutor

Source: Internet
Author: User

Tutor Time Limit: 2000/1000 MS (Java/others) memory limit: 65535/65535 K (Java/Others)
Total submission (s): 1981 accepted submission (s): 552


Problem descriptionlilin was a student of Tonghua Normal University. she is studying at University of Chicago now. besides studying, she worked as a tutor teaching Chinese to Americans. so, she can earn some money per month. at the end of the year, Lilin wants to know his average monthly money to decide whether continue or not. but she is not good at calculation, so she ask for your help. please write a program to help Lilin to calculate the average money her earned per month.
Inputthe first line contain one integer T, means the total number of cases.
Every case will be twelve lines. Each line will be contain the money she earned per month. Each number will be positive and displayed to the penny. No dollar sign will be supported ded.
Outputthe output will be a single number, the average of money she earned for the twelve months. it will be rounded to the nearest penny, preceded immediately by a dollar sign without tail zero. there will be no other spaces or characters in the output.
Sample Input
2 100.00 489.12 12454.12 1234.10 823.05 109.20 5.27 1542.25 839.18 83.99 1295.01 1.75100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00
 
Sample output
$1581.42 $100
Precision questions must be accurate to the minute, that is, the second digit after the decimal point. Therefore, we should look at the value of the third digit of the decimal point, and then round it to five.

If you increase the average value by 0.005, the third digit can be filled with 5 digits.

# Include "stdio. H "# define n 12int main () {int N, I; Double A, s; scanf (" % d ", & N); While (n --) {S = 0; for (I = 0; I <n; I ++) {scanf ("% lf", & A); S + = ;} s/= 12; int M = (S + 0.005) * 100; // the third digit after the decimal point is rounded to If (M % 100 = 0) printf ("$ %. 0f \ n ", S); else if (M % 10 = 0) printf (" $ %. 1f \ n ", S); else printf (" $ %. 2f \ n ", S);} return 0 ;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.