1411052107-hd-the Calculation of GPA

Source: Internet
Author: User
Please calculate the calculation of GPA

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 19932 accepted submission (s): 4576

Problem description at the end of each semester, everyone is busy calculating their average score. This score is directly related to scholarship evaluation. Both foreign universities calculate GPa (grade point average), also known as GPR (grade point ratio), that is, the weighted average of score points and credits represents the score of a student. How can we calculate the GPA?

Calculation method adopted by General Universities

B80-89 3: 00
C70-79 2: 00
E0-59 0 point

For example, if a student takes three courses, the course subjects, credits, and scores are:
English: three credits, 92 points; Chemistry: Five credits, 80 points; mathematics: Two credits, 60 points, then the GPA algorithm is as follows:

Subject credit score points score × 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 indicates a certain GPA.
Below is a program for calculating GPA.
Input contains multiple groups of data. The first row of each group of data contains N numbers, and the next n rows indicate a score. Each row has two real-type numbers: S, P, and S, which indicate the credits of the course, and P indicates the score of the student (percentage ). If P =-1, it indicates that the student is absent from the test and should not be included.
Output outputs a row of data in each group, indicating the GPA of the student and retaining two decimal places. If the GPA does not exist, output-1.
Sample Input
33 925 802 60
Sample output
The question of how to solve the problem has been given very clearly, and it is for real type rather than integer type. Check if your program can determine whether the code 89.5 distinguishes between integers and decimals.
# Include <stdio. h> int in (double C) {int D; If (C >=90 & C <= 100) d = 4; else if (C> = 80 & C <90) // else if (C> = 80 & C <= 89) // do not ignore 89.5 d = 3; else if (C> = 70 & C <80) d = 2; else if (C> = 60 & C <= 70) d = 1; else if (C> = 0 & C <60) d = 0; else d =-1; return D ;}int main () {int N; Double A, B, suma, sumb; int I, j; while (scanf ("% d", & N )! = EOF) {Suma = sumb = 0; for (I = 0; I <n; I ++) {scanf ("% lf", &, & B); If (in (B )! =-1) {Suma + = A; sumb + = A * in (B) ;}} if (SUMA = 0) printf ("-1 \ n "); else printf ("%. 2lf \ n ", sumb/SUMA);} return 0 ;}

1411052107-hd-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.