Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- import static java.lang.Math.*;
- public class Main {
- public static void main(String[] args) {
- System.out.println("Podaj ilosc elementow: ");
- Scanner scanner = new Scanner(System.in);
- int quantity = scanner.nextInt();
- System.out.println("Podaj te liczby: ");
- int[] numbers = new int[quantity];
- double sum = 0.0;
- for(int i = 0; i < quantity; i++){
- numbers[i] = scanner.nextInt();
- sum += numbers[i]; //sum = sum + numbers[i] - to jest to samo
- }
- double avarage = sum / quantity;
- System.out.println("Srednia wynosi: " + avarage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment