Pages

Selasa, 20 September 2011

Jenis-jenis inputan pada java

CODING :
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author dark angel
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
     Scanner enthis= new Scanner(System.in);
     System.out.print("Input 1 : ");
     int bil1=enthis.nextInt();
     
     try{
     BufferedReader inp2 = new 
     BufferedReader(new InputStreamReader(System.in));

     String bil=" "; 
     System.out.println("Input 2 : ");
     int bil2 = Integer.parseInt(inp2.readLine());  
     
     int bil3 = Integer.parseInt(JOptionPane.showInputDialog("Input 3 : "));
     int rata=(bil1+bil2+bil3)/3;
     
     if(rata>80){
    JOptionPane.showMessageDialog(null,"rata anda : " + " " + rata +":)");  
    
    }else{
     JOptionPane.showMessageDialog(null,"rata anda : " + " " + rata +":( ");
    }
      
     }
        catch(Exception e){
        System.out.println(e);
        }
    }
}
OUTPUT :



0 komentar:

Posting Komentar