Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Wednesday, 11 November 2015
Kasus switch – case "pilih hari"
hai sobat kali ini saya akan memberikan source code untuk switch case untuk pemilihan hari..source code kali ini langsung ke public class ya....
contoh kasus if else untuk pilihan bilangan
public class modul3_d {
public static void main(String []args){
contoh kasus if else "pilihan umur"
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package praktikum;
/**
*
* @author asus
*/
public class modul3_c {
public static void main(String []args){
int umur = 19;
if (umur <=25)
{
System.out.println ("usia saya = "+umur);
System.out.println ("Anda masih Muda");
}
if (umur >25)
{
System.out.println ("usia saya = "+umur);
System.out.println("Anda sudah Tua");
}
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package praktikum;
/**
*
* @author asus
*/
public class modul3_c {
public static void main(String []args){
int umur = 19;
if (umur <=25)
{
System.out.println ("usia saya = "+umur);
System.out.println ("Anda masih Muda");
}
if (umur >25)
{
System.out.println ("usia saya = "+umur);
System.out.println("Anda sudah Tua");
}
}
}
contoh kasus if untuk bilangan positif & negatif
public class modul3_b {
public static void main(String []args){
int num=-4;
System.out.println ("masukkan bil anda = " +num);
if (num>=0)
{
System.out.println (num+"\tbil positif" );}
if(num<=0)
{
System.out.println(num+"\tbil negatif");
}
}
public static void main(String []args){
int num=-4;
System.out.println ("masukkan bil anda = " +num);
if (num>=0)
{
System.out.println (num+"\tbil positif" );}
if(num<=0)
{
System.out.println(num+"\tbil negatif");
}
}
contoh Kasus IF pada java
hai sobat kali ini saya akan menampilkan salah satu penggunaan if pada java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package praktikum;
/**
*
* @author asus
*/
public class Praktikum {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a=10,b=9;
if (a>b)
{
System.out.println("nilai 10>9 adalah benar");
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package praktikum;
/**
*
* @author asus
*/
public class Praktikum {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a=10,b=9;
if (a>b)
{
System.out.println("nilai 10>9 adalah benar");
}
}
}
Subscribe to:
Posts (Atom)