Selection-01 in Java

package IF_1Java; 

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

public class IF_1 { 
public static void main(String[] args) { 
  System.out.println("Masukan bilangan Anda : "); 
  BufferedReader bfr = new BufferedReader 
  (new InputStreamReader(System.in)); 
  String angkaInput = null; 
  try { 
     angkaInput = bfr.readLine(); 
 } catch (IOException e) { 
   e.printStackTrace(); } 
int Data = Integer.valueOf(angkaInput).intValue(); 
if (Data > 0) 
   System.out.print ("Bilangan Positif");
else if (Data < 0)
   System.out.print("Bilangan Negatif");
else
   System.out.print ("Anda memasukan bilangan Nol");




This source code explain on how to make selection using If in Java. This Source code show the program using BufferedReader that means a user save the data which inputted by user. Remember in Java there is no 'reserved word' looks like cin>> or scanf(" ") in C++ and C. The Statement of IOException explain us to handle if there is any errors, and The 'InputStreamReader' explain to input what the 'user defined ' for data that inputted.

Popular posts from this blog

Introduction to Use Case Diagram - Case study: Facebook

Sequential Search

Motivasi dan Semangat Menuntut Ilmu Agama Islam Sesuai Al-Qur’an dan Sunnah