Rabu, 20 April 2011

Contoh penggunaan BufferedReader pada java

import java.io.*;
public class Percobaan {
public static void main (String[]args)
{BufferedReader awal = new BufferedReader(new InputStreamReader(System.in));
String a ="";



System.out.println("Masukkan angka 20");
 try{
         a = awal.readLine();
        }catch (IOException e){
         System.out.println("Error!");}
BufferedReader kedua = new BufferedReader (new InputStreamReader (System.in));
String b = "";
System.out.println("Masukkan angka 12");
 try{    b = kedua.readLine();
        }catch (IOException e){
         System.out.println("Error!");}
BufferedReader ketiga = new BufferedReader (new InputStreamReader (System.in));
String c = "";
System.out.println("Masukkan angka 3");
 try{    c = ketiga.readLine();
        }catch (IOException e){
         System.out.println("Error!");}
           System.out.println("Nilai-nilai yang dimasukkan ="+a+","+b+","+c);
}}

Tidak ada komentar:

Posting Komentar