1. 程式人生 > 其它 >UVA11777 Automate the Grades【水題】

UVA11777 Automate the Grades【水題】

The teachers of “Anguri Begam Uccha Biddalya”, a school located in the western region of Sylhet, currently follows a manual system for grading their students. The manual process is very time consuming and error prone. From the next semester they have decided to purchase some computers so that the whole grading process can be automated. And yes, you guessed it — they have hired you to write a program that will do the job.

在這裡插入圖片描述

The grading of each course is based on the following weighted scale:
• Term 1 — 20%
• Term 2 — 20%
• Final — 30%
• Attendance — 10%
• Class — Tests 20%
The letter grades are given based on the total marks obtained by a student and is shown below:
• A ≥ 90%
• B ≥ 80% & ¡ 90%
• C ≥ 70% & ¡ 80%

• D ≥ 60% & ¡ 70%
• F < 60%
Term 1 and Term 2 exams are out of 20 each, F inal is out of 30 and Attendance given is out of 10. Three class tests are taken per semester and the average of best two is counted towards the final grade. Every class test is out of 20.
Example: Say Tara obtained marks of 15, 18, 25 and 8 in Term 1, Term 2, Final and Attendance respectively. Her 3 class test marks are 15, 12 and 17. Since average of best 2 will be counted, her class test mark will be equal to (15 + 17) / 2 = 16. Therefore, total marks = 15 + 18 + 25 + 8 + 16 = 82 and she will be getting a B.
Input
The first line of input is an integer T (T < 100) that indicates the number of test cases. Each case contains 7 integers on a line in the order T erm1 T erm2 F inal Attendance Class T est1 Class T est2 Class T est3.
All these integers will be in the range [0, total marks possible for that test].
Output
For each case, output the case number first followed by the letter grade {A B C D F}. Follow the
sample for exact format.
Sample Input
3
15 18 25 8 15 17 12
20 20 30 10 20 20 20
20 20 30 10 18 0 0
Sample Output
Case 1: B
Case 2: A
Case 3: B

問題連結UVA11777 Automate the Grades
問題簡述:成績轉換問題,計算等級成績。
問題分析:簡單題,不解釋。
程式說明:(略)
參考連結:(略)
題記:(略)

AC的C++語言程式如下:

/* UVA11777 Automate the Grades */

#include <bits/stdc++.h>

using namespace std;

const int N = 7;
int a[N];

int main()
{
    int t;
    scanf("%d", &t);
    for (int k = 1; k <= t; k++) {
        for (int i = 0; i < N; i++) scanf("%d", &a[i]);
        sort(a + 4, a + N);

        int sum = 0;
        for (int i = 0; i < 4; i++) sum += a[i];
        sum += (a[N - 2] + a[N - 1]) / 2;

        char ans;
        if (sum >= 90) ans = 'A';
        else if (sum >= 80) ans ='B';
        else if (sum >= 70) ans = 'C';
        else if (sum >= 60) ans = 'D';
        else ans = 'F';

        printf("Case %d: %c\n", k, ans);
    }

    return 0;
}