Advertisement
porteno

תרגיל מספר 1

Sep 24th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Grades_Avgrage {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. int grade1, grade2, grade3, grade4;
  8. int sum = 0;
  9. double avg = 0;
  10.  
  11. System.out.println("Enter the 1st grade:");
  12. grade1 = in.nextInt();
  13.  
  14. System.out.println("Enter the 2nd grade:");
  15. grade2 = in.nextInt();
  16.  
  17. System.out.println("Enter the 3th grade:");
  18. grade3 = in.nextInt();
  19.  
  20. System.out.println("Enter the 4th grade:");
  21. grade4 = in.nextInt();
  22.  
  23. sum = grade1 + grade2 + grade3 + grade4;
  24. avg = (double) sum/4;
  25.  
  26. System.out.println("the avrage is: "+avg);
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement