Google Translate

Kalkulator+Perulangan+perbandingan+stop (Java)

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);
}
}
}
               

Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© ILMU TEKNIK INFORMATIKA
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0
Posts RSSComments RSS
Back to top