..:Welcome to My Blog:..

Clock

Entri Populer

Powered By Blogger

Total Tayangan Halaman

Pages

Menerima Inputan dari Keyboard menggunakan BufferedReader

Script :
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class T2_BufferedReader {

    public static void main(String[] args) {
        String angka1, angka2, angka3;
        int bil1, bil2, bil3, counter;
        float average;
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        try {
            System.out.print("Masukkan Bilangan ke-1 : ");
            angka1 = input.readLine();
            bil1 = Integer.parseInt(angka1);
            System.out.print("Masukkan Bilangan ke-2 : ");
            angka2 = input.readLine();
            bil2 = Integer.parseInt(angka2);
            System.out.print("Masukkan Bilangan ke-3 : ");
            angka3 = input.readLine();
            bil3 = Integer.parseInt(angka3);
            counter = bil1 + bil2 + bil3;
            average = counter / 3;
            System.out.println("-----------------------------------");
            System.out.println("Jumlah Bilangan        : " + counter);
            System.out.println("Rata - Rata Bilangan   : " + average);
        } catch (Exception e) {
        }
    }
}

Implementasi :


Output :


0 komentar:

Posting Komentar

Pengikut