/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package nilaimaxmin;
/**
*
* @author oscar
*/
import java.util.Scanner;
public class NilaiMaxMin {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int [] bil = new int[10];
int n,maks, min;
Scanner x = new Scanner(System.in);
System.out.print("Berapa data (maks 10) : ");
n = x.nextInt();
/* mengisi array */
for (int i=0;i<n;i++){
Scanner b = new Scanner(System.in);
System.out.print("Data ke-"+i+" :");
bil[i] = b.nextInt();
}
/* mencari nilai maksimum minimum*/
maks=bil[1];
for (int i=0;i<n;i++){
if (bil[i]>maks){
maks=bil[i];
}
}
System.out.println("Nilai maksimumnya adalah: "+maks);
min=bil[1];
for (int i=0;i<n;i++){
if (bil[i]<min){
min=bil[i];
}
}
System.out.println("Nilai minimumnya adalah: "+min);
}
}
Sign up here with your email
ConversionConversion EmoticonEmoticon