luas dan keliling bola,segitiga siku-siku, dan Lingkaran

Sharing for java newbie if you senior java don’t read this my suggestion..hehehe…,I hopefully for newbie java…
luas dan keliling bola

import java.io.*;

public class LuasBola {

    public static void main(String[] args) {
		BufferedReader m = new BufferedReader(new InputStreamReader(System.in));
		double phi = 3.14;
		double kel;
		double luas;
		int r;
		int kel2;
		String jarijari2 = " ";
		int kuadrat;
		try{
			System.out.println("Masukkan jarijari: ");
			jarijari2 = m.readLine();
			}catch(IOException e){
			System.out.println(e);
			}
		r = Integer.parseInt(jarijari2);
		kuadrat = r * r;
		kel = 4*phi*kuadrat;
		luas = kel*r/3;

		System.out.println("keliling bola : " + kel );
		System.out.println("Luas bola: " + luas);
    }
}

luas lingkaran.

import java.io.*;

public class LuarLingkaran {

    public static void main(String[] args) {
		double phi = 3.14;
		int r;
		String jarijari= " ";
		BufferedReader m = new BufferedReader(new InputStreamReader(System.in));
		int jumlah;
		int konstanta;
		double hasil;
		try{
			System.out.println("Hitung jari-jari : ");
			jarijari = m.readLine();
			}catch(IOException e){
			System.out.println(e);
			}
		r = Integer.parseInt(jarijari);
		jumlah = r * r;
		hasil = phi * jumlah;
		System.out.println("Total Luas Lingkaran: " + hasil);
    }
}

Keliling segitiga dan sisimiring

import java.math.*;
import java.io.*;
public class kelilingsegitiga {

    public static void main(String[] args) {
		int p;
		int t;
		double pangkat = 2;
		double pang = 0.5;
		double sisimiring;
		double ketsiku;
		String panjang = " ";
		String tinggi = " ";
		BufferedReader m = new BufferedReader(new InputStreamReader(System.in));
		try{

			System.out.println("masukkan panjang : ");
			panjang = m.readLine();
			System.out.println("masukkan tinggi : ");
			tinggi = m.readLine();
			}catch(IOException e){
			System.out.println(e);
			}
		p = Integer.parseInt(panjang);
		t = Integer.parseInt(tinggi);
		sisimiring = Math.pow((Math.pow(p,pangkat)+Math.pow(t,pangkat)),pang);
		ketsiku = p+t+sisimiring;

		System.out.println("panjang sisi miring : " + sisimiring);
		System.out.println("keliling segitiga siku-siku " + ketsiku);
    }
}

terima kasih sudah membaca semoga bermanfaat bagi newbie di java…,jika ada kesalahan silahkan comment memang diatas sengaja tidak memakai salah satu library java.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s