Advertisement
Arifin99

Task1 192-35-2861

Jun 10th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package task;
  2. import java.util.Scanner;
  3. public class work {
  4.     public static void main(String[] args) {
  5.         Scanner input =new Scanner(System.in);
  6.         double total_sum=0;
  7.         double sum=0;
  8.         double total_credit=0;
  9.         double[] grade = new double[5];
  10.         double[] credit = new double[5];
  11.         System.out.println("Enter the grades:");
  12.         for( int i=0; i<5; i++){
  13.             grade[i]= input.nextDouble();
  14.         }
  15.         System.out.println("Enter the credits:");
  16.         for( int i=0; i<5; i++){
  17.             credit[i]= input.nextDouble();
  18.             total_credit=total_credit + credit[i];
  19.         }
  20.         for( int i=0; i<5; i++){
  21.             sum= (grade[i]*credit[i]);
  22.             total_sum = total_sum + sum;
  23.         }
  24.         double gpa = total_sum/total_credit;
  25.         System.out.println("the GPA is:"+gpa);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement