//公式:(成绩*学分)/学分
package test01;
import java.util.Scanner;
public class Gpa {
public static void main(String[] args) {
float []grade=new float[6];
float credit[]=new float[6];
float credit1[]=new float[6];
float gc=0,c=0;
float GPA;
Scanner sc = new Scanner(System.in);
System.out.println("请输入一学生各科成绩:");
for(int i=0;i<6;i++)
grade[i]=sc.nextInt();
System.out.println("请输入各门课学分:");
for(int i=0;i<6;i++)
credit[i]=sc.nextInt();
for(int i=0;i<6;i++)
{
if(grade[i]>=85&&grade[i]<=100)
credit1[i]=4;
else if(grade[i]>=75)
credit1[i]=3;
else if(grade[i]>=60)
credit1[i]=2;
else if(grade[i]>=45)
credit1[i]=1;
else if(grade[i]<=44)
credit1[i]=0; }
for(int i=0;i<6;i++)
{
gc+=grade[i]*credit1[i];
c+=credit[i];
}
GPA=gc/c;
System.out.println("该学生的GPA为"+GPA);
}
}