Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class graduation21 {
  4. public static void main(String[] args) {
  5. Scanner scan= new Scanner(System.in);
  6. String student=scan.nextLine();
  7. double totalgrade=0;
  8. int classcount=1;
  9. int expellcount=0;
  10. boolean isexpelled=false;
  11. while(classcount<=12)
  12. {double grade= Double.parseDouble(scan.nextLine());
  13. if (grade>=4)
  14. {
  15. classcount++;
  16. totalgrade+=grade;
  17. }
  18. else{expellcount++;}
  19. if(expellcount==2)
  20. {isexpelled=true;}}
  21. if(isexpelled)
  22. {
  23. System.out.printf("%s has been excluded at %d grad",student,classcount);
  24. }
  25. else {
  26. System.out.printf("%s graduated. Average grade: %.2f", student,totalgrade/12);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement