Blogger

Senin, 18 November 2013

Mencari Nilai Rata-rata BufferedReader Menggunakan Eclipse



package Respon3;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Nilai_Rata2_BufferedReader {
      public static void main(String [] args){
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
                        String n="", m="", o="";
                             
                        try{
                        System.out.print("Masukkan angka pertama = ");
                        n = input.readLine();
                        System.out.print("Masukkan angka kedua = ");
                        m = input.readLine();
                        System.out.print("Masukkan angka ketiga = ");
                        o = input.readLine();}
                        catch (IOException e){}
                             
                        int bil1, bil2, bil3, rata;
                             
                        bil1 = Integer.parseInt(n);
                        bil2 = Integer.parseInt(m);
                        bil3 = Integer.parseInt(o);
                             
                        rata = (bil1 + bil2 + bil3)/3;
                             
                         System.out.println("Rata-rata nilai Anda: "+ rata);
                                 if (rata >= 60){System.out.println(":-)");
                                }
                                else {
                                 System.out.println(":-(");                                             }

                  }
      }


Hasil:

0 komentar:

Posting Komentar