[Java] Praktikum 4 : Coba jari-jari lingkaran

-[Java]  Praktikum 4 : Coba jari-jari lingkaran- ini merupakan lanjutan dari postingan : ALGORITMA DAN PEMROGRAMAN MODUL 1 SUB PRO...

-[Java] Praktikum 4 : Coba jari-jari lingkaran-
ini merupakan lanjutan dari postingan :

ALGORITMA DAN PEMROGRAMAN

MODUL 1 SUB PROGRAM (Procedure & Function).


d. Praktikum 4

public class CobaLingkaran_1
{
    private double jariJari;


    public void Lingkaran() //prosedur1
    {
    setJariJari (1);
    }

    public void setJariJari (double r) //prosedur2 dengan parameter
    {
    if (r > 0) jariJari = r;
    }

    public double getJariJari() //function1
    {
    return (jariJari);
    }
    public double hitungLuas() //function2
    {
    return (Math.PI * jariJari * jariJari);
    }

    public double hitungKeliling() //function3
    {   
    return (Math.PI * 2.0 * jariJari);
    }

public static void main(String[] salman)
{

CobaLingkaran_1 abc = new CobaLingkaran_1();
CobaLingkaran_1 def = new CobaLingkaran_1();
CobaLingkaran_1 ghi = new CobaLingkaran_1();

System.out.println("Data default");
System.out.println("------------");
System.out.println("Jari-jari ABC: " +abc.getJariJari());
System.out.println("Jari-jari DEF: " +def.getJariJari());
System.out.println("Jari-jari GHI: " +ghi.getJariJari());

System.out.println();
abc.setJariJari(5);
def.setJariJari(23);
ghi.setJariJari(10);

System.out.println("Data sekarang");
System.out.println("------------");
System.out.println("Jari-jari ABC: " + abc.getJariJari());
System.out.println("Jari-jari DEF: " + def.getJariJari());
System.out.println("Jari-jari GHI: " + ghi.getJariJari());
System.out.println();
}
}
Hasil Output :













Demikian contoh  Pratikum (Procedure dan Function). semoga bermanfaat.

COMMENTS

BLOGGER

Nama

Artikel,66,Cerita singkat,82,Java,12,SEO,15,Tahukah sobat??,21,Tips dan Trik,15,Tips.....n' Trick.....,14,Tutorial,20,Tutorial Blogger,50,
ltr
item
Blog Salman Syuhada: [Java] Praktikum 4 : Coba jari-jari lingkaran
[Java] Praktikum 4 : Coba jari-jari lingkaran
https://4.bp.blogspot.com/-BkHYtO3Hn34/T8HOOc31yWI/AAAAAAAABTA/Ydw6TrS1Qz8/s1600/java.jpeg
https://4.bp.blogspot.com/-BkHYtO3Hn34/T8HOOc31yWI/AAAAAAAABTA/Ydw6TrS1Qz8/s72-c/java.jpeg
Blog Salman Syuhada
http://blog.salmansyuhada.com/2012/05/praktikum-4.html
http://blog.salmansyuhada.com/
http://blog.salmansyuhada.com/
http://blog.salmansyuhada.com/2012/05/praktikum-4.html
true
5369818979434965955
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy