Syafi'i Blog's'

Minggu, 19 Juli 2009

ujian PBO yg bikin orang pusing.....

public class calculate
{
public static void main (String[] args)
{
int y,x;
x=1;y=0;
while (1<=10)
{
sum+=x;
++x;y--;
}
System.out.print(x);
}
}
C:\Documents and Settings\crystal\My Documents\calculate.java:17: cannot find symbol
symbol : variable sum
location: class calculate
sum+=x;
^
1 error

Process completed.
-----------------------------------------
public class gambar
{
public static void main (String[] args)
{
int x=1;
while(x<=10)
{
System.out.println(x%2==1?"****":"+++++++");
x++;
}
}
}

****
+++++++
****
+++++++
****
+++++++
****
+++++++
****
+++++++

Process completed.
-----------------------------------------
public class logikaoperator
{
public static void main (String[] args)
{
System.out.printf("%s\n%s:%b\n%s:%b\n%s:%b\n%s:%b\n\n","Conditional AND (&&)","false&&false",(false&&false),"false&&true",(false&&true),"true&&false",(true&&false),"true&&true",(true&&true));
System.out.printf("%s\n%s:%b\n%s:%b\n%s:%b\n%s:%b\n\n","Conditional OR (||)",
"false||false",(false||false),"false||true",(false||true),"true||false",(true||false),"true|true",(true||true));
System.out.printf("%s\n%s:%b\n%s:%b\n%s:%b\n%s:%b\n\n","Boolean Logika AND (&)",
"false&false",(false&false),"false&true",(false&true),"true&false",(true&false),"true&true",(true&true));
System.out.printf("%s\n%s:%b\n%s:%b\n%s:%b\n%s:%b\n\n","Boolean Logika inclusive OR (|)",
"false|false",(false|false),"false|true",(false|true),"true|false",(true|false),"true|true",(true|true));
System.out.printf("%s\n%s:%b\n%s:%b\n%s:%b\n%s:%b\n\n","Boolean Logika exclusive OR (^)",
"false^false",(false^false),"false^true",(false^true),"true^false",(true^false),"true^true",(true^true));
System.out.printf("%s\n%s:%b\n%s:%b\n","Logika NOT (!)","!false",(!false),"!true",(!true));
}
}

Conditional AND (&&)
false&&false:false
false&&true:false
true&&false:false
true&&true:true

Conditional OR (||)
false||false:false
false||true:true
true||false:true
true|true:true

Boolean Logika AND (&)
false&false:false
false&true:false
true&false:false
true&true:true

Boolean Logika inclusive OR (|)
false|false:false
false|true:true
true|false:true
true|true:true

Boolean Logika exclusive OR (^)
false^false:false
false^true:true
true^false:true
true^true:false

Logika NOT (!)
!false:true
!true:false

Process completed.

0 komentar:

Template by : auraipank x-template.blogspot.com