Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class averageloop{
  4.  
  5. public static void main(String[] args){
  6.  
  7.  
  8. Scanner input = new Scanner(System.in);
  9.  
  10. System.out.print("How many exams have you taken");
  11.  
  12. int exam = input.nextInt();
  13.  
  14. double i;
  15.  
  16. //Loop through however many times is inputed
  17. for(i = 0; i< exam; i++){
  18.  
  19. System.out.println("Enter Your Scores: ");
  20.  
  21. points = input.next();
  22.  
  23. double totalpoints = totalpoints + points;
  24.  
  25. }
  26.  
  27. double avg;
  28.  
  29. avg = (totalpoints / i);
  30.  
  31. System.out.println("Your average is " + avg);
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement