Hangzhou Electric HDU 1202 The calculation of GPA

Source: Internet
Author: User

The calculation of GPA Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 21897 Accepted Submission (s): 5028


Problem description at the end of each semester, everyone will be busy calculating their average results, which is directly related to the evaluation of scholarships. Foreign universities are computing GPA (grade point average), also known as GPR (grade points ratio), which is the weighted average of scores and credits to represent a student's performance. So how do you calculate GPA?

The scoring method adopted by the General university

A90-100 4 points
B80-89 3 points
C70-79 2 points
D60-69 1 points
e0-59 0 Points

For example: A student who has studied three classes, the subjects, credits and achievements are:
English: Three credits, 92 points; Chemistry: Five credits, 80 points; Mathematics: Two credits, 60 points, the GPA algorithm is as follows:

Account credits fractional points x points
English 3 92 4 12
Chemistry 5 80 3 15
Mathematics 2 60 1 2
Total 10 29
29/10=2.9
2.9 is the GPA of a born
Here you write a program for calculating GPA.

Input contains more than one set of data, and the first row of each group of data has a number n, and the next row of n rows represents a score. Each line has two actual number S,p,s represents the course's credit, p indicates the student's score (percentile). If p=-1 The student This course lacks the examination, should not be counted.

Output outputs a row for each set of data, representing the student's GPA, which retains two decimal places. If GPA does not exist, output-1.

Sample Input
33 925 802 60

Sample Output
2.90

Authorspeakless
Sourcegardon-dygg Contest 2

have to say two, MA, the score is real, with the whole type WA n times is enough, the topic has a not clear place is the score is negative one time

His credit to the

#include <iostream>using namespace Std;int main () {int N;while (cin>>n) {double t,score,sum=0, st=0;for (int i =0;i<n;i++) {cin>>t>>score;if (score==-1) Continue;else if (score>=90&&score<=100) {sum +=4*t;st+=t;} else if (score>=80) {sum+=3*t;st+=t;} else if (score>=70) {sum+=2*t;   st+=t;} else if (score>=60) {sum+=1*t;st+=t;} else if (score>=0) {st+=t;}} if (ST) printf ("%.2lf\n", sum*1.0/st); Elsecout<<-1<<endl;} return 0;}


It doesn't seem to add.

Hangzhou Electric HDU 1202 The calculation of GPA

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.