You are on page 1of 1

import java.util.

Scanner;

public class Counter{


public static void main(String args[]){
Scanner input = new Scanner(System.in);
int counter = 1, unit, totalUnit = 0;
float grades, sum = 0, gpa = 0, product = 0;

while(counter<=7){
System.out.println("Subject " + counter);
System.out.print("Enter grade: ");
grades = input.nextFloat();
System.out.print("Enter number of units: ");
unit = input.nextInt();
totalUnit += unit;
product = grades *(float)unit;
sum += product;
gpa = sum/(float)totalUnit;
counter++;
}
System.out.println("\nSum of grades = " + sum);
System.out.println("Total Units = " + totalUnit);
System.out.println("GPA = " + gpa);

System.out.println(gpa>=3 ? "PASSED" : "FAILED");


}
}

This study source was downloaded by 100000853281575 from CourseHero.com on 03-17-2023 07:29:38 GMT -05:00

https://www.coursehero.com/file/96543325/Counterjava/
Powered by TCPDF (www.tcpdf.org)

You might also like