Be Happy

My Bestfriends know that I'm compeletely insane!♥

Forever Young

when your bestfriends is the only one who understand you♥

Only You

Thanks for being my bestfriends

FRIENDSHIP

is when people know all about you but like you anyway

Friends are like stars

they come and go but the ones that stay are the ones that glow

Selasa, 15 Desember 2015

Tugas OOP Bola

Ini adalah salah satu contoh penggunaan oop:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tugasoopbola;
import java.util.Scanner;
/**
 *
 * @author Personalise Notebook
 */
class bola{
    double volume, luaspermukaan, r;
    Scanner sc = new Scanner (System.in);
   
    public bola () {
        System.out.println("-Menghitung luas permukaan dan volume bola-");
        System.out.println("");
    }
   
    public void luaspermukaan () {
        System.out.println("LUAS PERMUKAAN BOLA");
        System.out.print("Masukkan jari-jari (cm) : ");
        r = sc.nextDouble();
        System.out.println("Luas permukaan = 4* 3.14 *"+r);
        luaspermukaan = 4* 3.14 * r;
        System.out.print("Luas permukaan bola adalah = "+ luaspermukaan +"cm");
        System.out.println("");
    }
   
    public void volume () {
        System.out.println("");
        System.out.println("VOLUME SEGITIGA");
        System.out.print("Masukkan jari-jari bola (cm) : ");
        r = sc.nextDouble();
        System.out.println("Volume = 4/3 * 3.14 *"+r+"*"+r+"*"+r);
        volume = 4/3 * 3.14 * r * r * r;
        System.out.print("Volume bola adalah = " + volume + "cm");
    }
}
public class Tugasoopbola {
    public static void main (String [] args ) {
        bola sc = new bola ();
        sc.luaspermukaan();
        sc.volume();
    }
   
}

Dibawah ini adalah outputnya:

Twitter Delicious Facebook Digg Stumbleupon Favorites More