Advertisement
zerosensitivity

loop5

Oct 21st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Loops5 {
  4.  
  5. static double [] scores;
  6. static Scanner input = new Scanner(System.in);
  7.  
  8.  
  9.  
  10. public static void main(String[] args) {
  11.  
  12. System.out.println("How many scores to enter?");
  13. int sizeofarray = input.nextInt();
  14.  
  15. scores = new double [sizeofarray];
  16.  
  17.  
  18.  
  19.  
  20. }
  21.  
  22. public static void input() {
  23.  
  24. for(int i=0; i < scores.length; i++)
  25. {
  26. System.out.println("enter score");
  27. scores[i] = input.nextDouble();
  28. }
  29. System.out.println("all marks entered");
  30. output();
  31.  
  32. }
  33.  
  34. public static void output() {
  35.  
  36. for(int i=0; i<scores.length; i++)
  37. {
  38.  
  39. System.out.println(scores[i]);
  40. }
  41.  
  42. }
  43. public static void calcAverage() {
  44.  
  45. double total = 0;
  46. for (int i=0; i<scores.length; i++)
  47. {
  48. total = total + scores[i];
  49. }
  50.  
  51. double average = total/scores.length;
  52. System.out.println("The average is"+average);
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement