Topic 1133: Points of Merit (C++/java)

Source: Internet
Author: User

Title Description:

Peking University performed an average credit score point system (GPA) for undergraduates. The students ' actual scores will be calculated according to the different credits of different disciplines.
The formula is as follows:
Actual performance points
90--100 4.0
85--89 3.7
82--84 3.3
78--81 3.0
75--77 2.7
72--74 2.3
68--71 2.0
64--67 1.5
60--63 1.0
60 or less 0
1. The grade point of a course = the performance point * the course credit
2. Points of achievement = sum of all academic points and/or all course credits
You are asked to write a program to find out the rating points (GPA) for someone a.

Input:

Number of total courses in the first line n (n<10);
The second line of the corresponding course credit (two credits separated by a space);
The third line corresponds to the actual score of the course;
All the numbers entered here are integers.

Output:

Output has a row, the performance points, accurate to the decimal point after 2 decimal places. (printf ("%.2f", GPA);)

Sample input:
54 3 4 2 391 88 72 69 56
Sample output:
2.52
Import Java.text.decimalformat;import Java.util.Scanner;        public class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in);        DecimalFormat decimal_format=new DecimalFormat ("#.00");        int total_course;        int i,j,k;        int [] course_gpa=new int[10];        int [] course_grades=new int [10];            while (Cin.hasnext ()) {int total_gpa=0;            float sum=0;            Total_course=cin.nextint ();                for (i=0;i<total_course;i++) {course_gpa[i]=cin.nextint ();            Total_gpa+=course_gpa[i];            } for (j=0;j<total_course;j++) {course_grades[j]=cin.nextint ();                    } for (k=0;k<total_course;k++) {if (course_grades[k]>=90) {                SUM+=4.0*COURSE_GPA[K]; } if ((course_grades[k]>=85) && (course_grades[k]<=89)) {sum+=3.7*course_gpa[k]; } if ((course_grades[k]>=82) && (course_grades[k]<=84)) {sum+                =3.3*COURSE_GPA[K]; } if ((course_grades[k]>=78) && (course_grades[k]<=81)) {sum+                =3.0*COURSE_GPA[K]; } if ((course_grades[k]>=75) && (course_grades[k]<=77)) {sum+                =2.7*COURSE_GPA[K]; } if ((course_grades[k]>=72) && (course_grades[k]<=74)) {sum+                =2.3*COURSE_GPA[K]; } if ((course_grades[k]>=68) && (course_grades[k]<=71)) {sum+                =2.0*COURSE_GPA[K]; } if ((course_grades[k]>=64) && (course_grades[k]<=67)) {sum+ =1.5*course_gpa[K]; } if ((course_grades[k]>=60) && (course_grades[k]<=63)) {sum+                =1.0*COURSE_GPA[K];                } if (course_grades[k]<60) {sum+=0.0*course_gpa[k];            }}//system.out.println ("Total points" +sum+ "" + "Total Credits" +total_gpa);            System.out.print (Decimal_format.format (SUM/TOTAL_GPA));        System.out.print ("\ n");    }}}/************************************************************** problem:1133 User:carvin Language:java result:accept****************************************************************/

reproduced in C + +:

#include <stdio.h>double scorepoint (int a) {if (a>=90) return 4.0;     else if (a>=85) return 3.7;     else if (a>=82) return 3.3;     else if (a>=78) return 3.0;     else if (a>=75) return 2.7;     else if (a>=72) return 2.3;     else if (a>=68) return 2.0;     else if (a>=64) return 1.5;     else if (a>=60) return 1.0; else return 0;     } int main () {int i,n,sum;//n total number of courses sum of all course credits and double psum;//all academic points and int a[10],b[10];     Freopen ("C:\\users\\sjf\\desktop\\acm.txt", "R", stdin);         while (scanf ("%d", &n)! = EOF) {sum = 0;         psum = 0;             Enter course credits for (i = 0;i < n;i++) {scanf ("%d", &a[i]);         Sum of all course credits + + a[i];             }//Enter the actual score for the course for (i = 0;i < n;i++) {scanf ("%d", &b[i]);         The grade point of a course = the performance point * The course credit Psum + = Scorepoint (B[i]) * A[i];     } printf ("%.2f\n", psum/sum); } return 0; } /******problem:1133 User:carvin language:c++ Result:acce pted time:0 Ms memory:1020 kb****************************************************************/



Topic 1133: Points of Merit (C++/java)

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.