import
java.io.* ;
public
class
rata2{
public
static
void
main(String Arg[])
throws
IOException{
int
nilai[] ;
nilai =
new
int
[
20
] ;
double
rata =
0
, total =
0
;
int
nmax=
0
;
int
nmin=
1000
;
String str ;
int
i, jdata ;
BufferedReader Get=
new
BufferedReader(
new
InputStreamReader(System.in)) ;
System.out.println(
"Menghitung Nilai Rata Rata"
) ;
System.out.print(
"Jumlah Data :"
) ; str = Get.readLine() ;
jdata = Integer.parseInt(str) ;
for
(i =
0
; i
System.out.print(
"Nilai ke : "
+ (i+
1
) +
" : "
) ;
str = Get.readLine() ;
nilai[i] = Integer.parseInt(str) ;
}
rata =
0
; total =
0
;
System.out.println(
"Menghitung Nilai Rata Rata"
) ;
for
(i =
0
; i
System.out.println(
"Nilai ke : "
+ (i+
1
) +
" : "
+nilai[i]) ;
total = total + nilai[i] ;
if
(nilai[i]>nmax) nmax = nilai[i] ;
if
(nilai[i]
}
rata = total / jdata ;
System.out.println(
"Total Nilai : "
+ total) ;
System.out.println(
"Nilai Rata-Rata : "
+ rata) ;
System.out.println(
"Nilai Tertinggi : "
+ nmax) ;
System.out.println(
"Nilai Terendah : "
+ nmin) ;
}
}
Comments
Post a Comment