Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package task;
- import java.util.Scanner;
- public class work {
- public static void main(String[] args) {
- Scanner input =new Scanner(System.in);
- double total_sum=0;
- double sum=0;
- double total_credit=0;
- double[] grade = new double[5];
- double[] credit = new double[5];
- System.out.println("Enter the grades:");
- for( int i=0; i<5; i++){
- grade[i]= input.nextDouble();
- }
- System.out.println("Enter the credits:");
- for( int i=0; i<5; i++){
- credit[i]= input.nextDouble();
- total_credit=total_credit + credit[i];
- }
- for( int i=0; i<5; i++){
- sum= (grade[i]*credit[i]);
- total_sum = total_sum + sum;
- }
- double gpa = total_sum/total_credit;
- System.out.println("the GPA is:"+gpa);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement