Fat’s Albojongi

Just another WordPress.com weblog

prosedur dan fungsi di java

Posted by fatoni95 pada Februari 1, 2009

<!– /* Font Definitions */ @font-face {font-family:”Traditional Arabic”; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:178; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:8193 0 0 0 64 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:””; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:20.0pt; font-family:”Times New Roman”; mso-fareast-font-family:”Times New Roman”; mso-bidi-font-family:”Traditional Arabic”;} @page Section1 {size:612.1pt 936.1pt; margin:56.7pt 56.7pt 155.95pt 56.7pt; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} –>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:”Times New Roman”;
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}

Prosedur

import java.io.*;

class demosepeda

{

public static void main (String[ ] args)

{

sepedagunung spd = new sepedagunung();

spd.ubahgear(10);

spd.tambahspeed(50);

spd.ubahsadle(15);

spd.tampil();

spd.tampilsadle();

}

}

import java.io.*;

class sepedagunung extends sepeda

{

int sadle = 0;

public void ubahsadle (int tinggi)

{

sadle = sadle + tinggi;

}

public void tampilsadle()

{

System.out.println (“Tinggi sadle sepeda = ” + sadle);

}

}

import java.io.*;

class sepeda

{

int speed = 0;

int gear = 0;

public void ubahgear (int ubah)

{

gear = gear + ubah;

}

public void tambahspeed (int tambah)

{

speed = speed + tambah;

}

public void tampil()

{

System.out.println (“Gear = ” + gear + ” kecepatan = ” + speed);

}

}

import java.io.*;

class demomobil

{

public static void main (String[] args)

{

bus spd = new bus();

spd.ubahgear(7);

spd.tambahspeed(150);

spd.tampil();

spd.hiduptv();

spd.carichanel();

spd.tampilgambar();

}

}

import java.io.*;

class bus extends mobil

{

public void hiduptv ()

{

System.out.println (“TV Dihidupkan”);

}

public void carichanel ()

{

System.out.println (“Chanel sudah dicari”);

}

public void tampilgambar ()

{

System.out.println (“Gambar sudah ditampilkan”);

}

}

import java.io.*;

class mobil

{

int speed = 0;

int gear = 0;

public void ubahgear (int ubah)

{

gear = gear + ubah;

}

public void tambahspeed (int tambah)

{

speed = speed + tambah;

}

public void tampil()

{

System.out.println (“Gear = ” + gear + ” kecepatan = ” + speed);

}

}


import coba.latihanexe;

import coba.latihanexe2;

class packagess

{

public static void main (String[] arg)

{

latihanexe lat = new latihanexe();

latihanexe2 lat2 = new latihanexe2();

lat.tampil();

lat2.tampil2();

}

}

package coba;

public class latihanexe

{

public void tampil()

{

System.out.println (“Belajar membuat package”);

}

}

package coba;

public class latihanexe2

{

public void tampil2()

{

System.out.println (“Belajar membuat package 2”);

}

}


import java.io.*;

class matematika

{

//bilangan bulat

public int tambah (int x, int y)

{

return x + y;

}

public int kurang (int x, int y)

{

return x – y;

}

public int kali (int x, int y)

{

return x * y;

}

public int bagi (int x, int y)

{

return x / y;

}

//bilangan pecahan

public double tambah (double x, double y)

{

return x + y;

}

public double kurang (double x, double y)

{

return x – y;

}

public double kali (double x, double y)

{

return x * y;

}

public double bagi (double x, double y)

{

return x / y;

}

}

class tulis

{

public void tampil()

{

System.out.println(“Hallo”);

}

}

class panggilan

{

public static void main (String args[])

{

tulis x = new tulis();

x.tampil();

//manggil class dari file matematika

matematika m = new matematika();

//bilangan bulat

System.out.println (“Hasil = ” + m.tambah (5,5));

System.out.println (“Hasil = ” + m.kurang (5,5));

System.out.println (“Hasil = ” + m.kali (5,5));

System.out.println (“Hasil = ” + m.bagi (5,5));

//bilangan pecahan

System.out.println (“Hasil = ” + m.tambah (5.5,2.5));

System.out.println (“Hasil = ” + m.kurang (5.5,2.5));

System.out.println (“Hasil = ” + m.kali (5.5,2.5));

System.out.println (“Hasil = ” + m.bagi (5.5,2.5));

}

}

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: