Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. package omatjavat;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class tehtava21 {
  6.  
  7. static Scanner lukija = new Scanner(System.in);
  8.  
  9. public static void main(String[] args) {
  10.  
  11. int summa = 0;
  12. int temp = 0;
  13. int lukum = 0;
  14.  
  15. System.out.println("anna luku");
  16. temp = lukija.nextInt();
  17. summa = summa + temp;
  18. lukum = lukum + ((1 / temp) * (temp));
  19.  
  20. while (temp != 0) {
  21.  
  22. System.out.println("anna seuraava luku");
  23. temp = lukija.nextInt();
  24. summa = summa + temp;
  25. lukum = lukum + ((1 / temp) * (temp));
  26.  
  27. }
  28.  
  29. System.out.println("keskiarvo on " + ((summa) / (lukum)));
  30.  
  31. System.exit(0);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement