/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package latihan.pkgif.b2;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class LatihanIFB2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner masukan = new Scanner(System.in);
System.out.println("Masukkan bilangan");
int bilangan = masukan.nextInt();
if (bilangan%2 == 0){
System.out.println(bilangan);
System.out.println("Bilangan Genap");
}
else{
System.out.print(bilangan);
System.out.println("Bilangan Ganjil");
}
}
}
Manajement Informatika
Selasa, 13 Maret 2012
Contoh Program Java (Latihan IF B)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package latihan.pkgif.b;
/**
*
* @author Administrator
*/
public class LatihanIFB {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int suhu = 25;
if (suhu < 20)
System.out.println("Suhu dingin.");
else if (suhu < 30 )
System.out.println("Nyaman.");
else
System.out.println("Panas."); }
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package latihan.pkgif.b;
/**
*
* @author Administrator
*/
public class LatihanIFB {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int suhu = 25;
if (suhu < 20)
System.out.println("Suhu dingin.");
else if (suhu < 30 )
System.out.println("Nyaman.");
else
System.out.println("Panas."); }
}
Langganan:
Postingan (Atom)