import java.io.*;
public class coba {
public static void main (String[] args){
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
int [] angka = new int [100];
int min = 900;
int max = 0;
int total = 0;
float rata = 1;
float indexx = 0;
int i;
for (i= 1; i<angka.length ; i++){
System.out.print ("masukan angka ke "+i+ "[ketik 0 untuk stop] : ");
angka [i]=Integer.parseInt(in.readLine());
if (i>indexx){
indexx =i;
}
if (angka[i] == 0){
for (i= 1; i<angka.length ; i++){
total = total +angka[i];
rata = total / (indexx -1);
if (angka [i] < min){
if (angka [i] > 0){
min = angka [i];
}
}
if (angka [i]> max){
max = angka [i];
}
}
}
}
System.out.println ();
System.out.println("jumlah nilai : "+total);
System.out.println("rata-rata : "+rata);
System.out.println("nilai min : "+min);
System.out.println("nilai max : "+max);
}
catch (Exception e){
System.out.println (e);
}
}
}
public class coba {
public static void main (String[] args){
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
int [] angka = new int [100];
int min = 900;
int max = 0;
int total = 0;
float rata = 1;
float indexx = 0;
int i;
for (i= 1; i<angka.length ; i++){
System.out.print ("masukan angka ke "+i+ "[ketik 0 untuk stop] : ");
angka [i]=Integer.parseInt(in.readLine());
if (i>indexx){
indexx =i;
}
if (angka[i] == 0){
for (i= 1; i<angka.length ; i++){
total = total +angka[i];
rata = total / (indexx -1);
if (angka [i] < min){
if (angka [i] > 0){
min = angka [i];
}
}
if (angka [i]> max){
max = angka [i];
}
}
}
}
System.out.println ();
System.out.println("jumlah nilai : "+total);
System.out.println("rata-rata : "+rata);
System.out.println("nilai min : "+min);
System.out.println("nilai max : "+max);
}
catch (Exception e){
System.out.println (e);
}
}
}
0 comments