Berikut adalah source code untuk perhitungan operator pada java dengan menggunakan Netbeans
Souce code:
public class Percobaan3Operator { public int a,b;
boolean c,d,e;
double f,g;
public void testPercobaan3Operator()
{
a=19;
b=2;
c=true;
d=false;
e=!c;
g=0.2;
if (a%2==1)
b=a++;
else
b=a++;
f=(c&&!d||e)? a/g : a/(g+1);
System.out.println("a : "+a);
System.out.println("b : "+b);
System.out.println("e : "+e);
System.out.println("f : "+f);
}
public static void main(String[] args) {
Percobaan3Operator oper = new Percobaan3Operator();
oper.testPercobaan3Operator();
System.out.println(oper.checkMonth(9,2014));
}
public int checkMonth(int month,int year)
{
int day = 0;
if(month<8){
if (month%2==1) day=31;
else
if(month==2)
day = (year%4==0)? 29: 28;
else day=30;
} else {
if(month%2==1)
day=30; else day=31;
}
return day;
}
}
Output:
aaaa
BalasHapus