Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class UBTAgv {
- public static void main(String [] arg) {
- Scanner input = new Scanner(System.in);
- System.out.print("Sa elemente do t'i kete vargu: ");
- int ele = input.nextInt();
- double []v = new double[ele];
- for(int c = 0; c < v.length; c++) {
- System.out.print("Sheno elementin ne poziten " + c + ": ");
- v[c] = input.nextDouble();
- if(v[c] >= -88 && v[c] <= 100) {
- --c;
- System.out.println("Nuk lejohen numrat ne intervalin -88 ... 100");
- }
- }
- System.out.println("Mesatarja e vargut eshte " + avgInt(v));
- }
- public static int avgInt(double []x) {
- int sum = 0;
- for(int c = 0; c < x.length; c++) {
- sum += x[c];
- }
- return sum / x.length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement