Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myPkg;
- import java.util.Scanner;
- public class Ex04 {
- public static void main(String[] args) {
- int n = 5;
- Scanner in = new Scanner(System.in);
- int max = 0;
- int min = 100;
- int sum = 0;
- double avg;
- int pass = 0;
- System.out.println("Enter " + n + " grades:");
- for (int i = 0; i < n; i = i + 1) // i+=1
- {
- int x = in.nextInt();
- // max grade
- if (x > max)
- max = x;
- // min grade
- if (x < min)
- min = x;
- // average of grades
- sum = sum + x; // sum +=x;
- // pass number
- if (x >= 55)
- pass = pass + 1;
- }
- avg = 1.0 * sum / n; // avg = (double)sum/n;
- System.out.println("max grade is: " + max);
- System.out.println("min grade is: " + min);
- System.out.println("average is: " + avg);
- System.out.println("pass number is: " + pass);
- System.out.println("faild number is: " + (n - pass));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement