Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Loops5 {
- static double [] scores;
- static Scanner input = new Scanner(System.in);
- public static void main(String[] args) {
- System.out.println("How many scores to enter?");
- int sizeofarray = input.nextInt();
- scores = new double [sizeofarray];
- }
- public static void input() {
- for(int i=0; i < scores.length; i++)
- {
- System.out.println("enter score");
- scores[i] = input.nextDouble();
- }
- System.out.println("all marks entered");
- output();
- }
- public static void output() {
- for(int i=0; i<scores.length; i++)
- {
- System.out.println(scores[i]);
- }
- }
- public static void calcAverage() {
- double total = 0;
- for (int i=0; i<scores.length; i++)
- {
- total = total + scores[i];
- }
- double average = total/scores.length;
- System.out.println("The average is"+average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement