Last active
December 15, 2015 02:49
-
-
Save ecmelkytz/5190147 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
public class Array{ | |
public static void main(String args[]){ | |
ArrayList<Integer> liste = new ArrayList<Integer>(); | |
for (int i=0;i<5;i++) | |
liste.add(Integer.parseInt(JOptionPane.showInputDialog(null, "no gir:"))); | |
listeyiGoster(liste); | |
int buyuk=enBuyuk(liste); | |
int kucuk=enKucuk(liste); | |
JOptionPane.showMessageDialog(null, "en buyuk sayi:"+buyuk+"\nen kucuk sayi:"+kucuk+ | |
"\nortalama:"+ortalama(liste)); | |
Collections.sort(liste); | |
System.out.println("***Küçükten Büyüğe Sıralı Hali***"); | |
for (int i=0; i<liste.size();i++){ | |
System.out.println(liste.get(i)); | |
} | |
Collections.reverse(liste); | |
System.out.println("***Büyükten Küçüğe Sıralı Hali***"); | |
for (int i=0; i<liste.size();i++){ | |
System.out.println(liste.get(i)); | |
} | |
} | |
public static int enBuyuk(ArrayList<Integer> lis ){ | |
int ilk=0; | |
for(int a = 0; a < lis.size() ; a++){ | |
if (ilk <= lis.get(a)){ | |
ilk = lis.get(a); | |
} | |
} | |
return ilk; | |
} | |
public static int enKucuk(ArrayList<Integer> lis){ | |
int ilk=1000; | |
for(int i=0; i<lis.size();i++){ | |
if(ilk >= lis.get(i)){ | |
ilk = lis.get(i); | |
} | |
} | |
return ilk; | |
} | |
public static int ortalama(ArrayList<Integer> lis){ | |
int ilk=0; | |
int sonuc; | |
for(int i=0; i<lis.size(); i++){ | |
ilk+=(int)lis.get(i); | |
} | |
sonuc=ilk/lis.size(); | |
return sonuc; | |
} | |
private static void listeyiGoster(ArrayList<Integer> mList) { | |
for (int i = 0; i < mList.size(); i++) { | |
System.out.println(i + " -> " + mList.get(i)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment