Sabtu, 04 September 2010

Latihan Java Newbie

Playing JRock : Smakin Sendiri :(

Setelah kita berhasil melakukan instalasi java (JDK) skarang kita akan coba membuat beberapa latihan dengan java. ya buat memperlancar memahami lingkungan java terutama cara penulisan script, kompilasi dan menjalankannya...


Menampilkan Hallo
class lat{
public static void main(String args[]){
System.out.println("Hallo ..");
}
}

maka akan tampil kata Hallo ..


Script
class lat1{
public static void main(String args[]){
System.out.println("=======================");
System.out.println("Nama : Dian Heryana");
System.out.println("Alamat : Majalengka");
System.out.println("=======================");
}
}

Output:

=======================
Nama : Dian Heryana
Alamat : Majalengka
=======================


Script

class lat3 {
public static void main(String args[]){

int a;
a=80;

System.out.println("===================");
System.out.println("Nim : 2008102080");
System.out.println("Nama : Dian Heryana");
System.out.println("Nilai : " + a);
System.out.println("===================");
}
}

Output:

=======================
Nim : 2008102080
Nama : Dian Heryana
Nilai : 80
=======================


class lat4{
public static void main(String args[]){
int nilai;
nilai = 80;

System.out.println("==============");
System.out.println("Nim : 2008102080");
System.out.println("Nama : Dian Heryana");
System.out.println("Nilai : " +nilai);
if (nilai > 75)
System.out.println("Mutu : Baik");
else
System.out.println("Mutu : Kurang");

System.out.println("==============");
}
}

Output:

=======================
Nim : 2008102080
Nama : Dian Heryana
Nilai : 80
Mutu : Baik
=======================


Script:

class lat5{
public static void main(String args[]){
int nilai;
String nim,nama;
nilai = 80;
nim = 2008102080;
nama = DianHeryana;
System.out.println("==============");
System.out.println("Nim : " +nim);
System.out.println("Nama : " +nama);
System.out.println("Nilai : " +nilai);
if (nilai>=90 & nilai<100)>
System.out.println("Mutu : Istimewa" );
if (nilai>=80 & nilai<90)>
System.out.println("Mutu : Baik Sekali" );
else System.out.println("Mutu : Baik" );
System.out.println("==============");
}
}

Output:
=======================
Nim : 2008102080
Nama : Dian Heryana
Nilai : 80
Mutu : Baik Sekali
=======================

Silakan Coba yang ini
class lat6{ public static void main(String args[]){
int nilai;
nilai = 10;
System.out.println("=========================");
System.out.println("Nim : 2008102080");
System.out.println("Nama : Dian Heryana");
System.out.println("Nilai : " +nilai);
if (nilai>100)
System.out.println("Mutu : Nilai Tidak Benar" );
if (nilai>=90 & nilai<101)>
System.out.println("Mutu : Istimewa" );
if (nilai>=80 & nilai<89)>
System.out.println("Mutu : Baik Sekali" );
if (nilai>=70 & nilai<79)>
System.out.println("Mutu : Baik" );
if (nilai>=60 & nilai<69)>
System.out.println("Mutu : Cukup" );
if (nilai<60)>
System.out.println("Mutu : Kurang" ); System.out.println("=========================");

}
}

Hasilnya ???

created by : dian heryana

sorry i'm newbie

Tidak ada komentar:

Home Again

Bismillah Waktunya pulang.. Alhamdulillah