Hitungan Matematika


*** MENGHITUNG LINGKARAN

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modul7;
import java.io.*;
public class Soal1 {
    public double luas_lingkaran(int diameter) {
       
int jari2=diameter/2;
double luas=Math.PI * Math.pow(jari2,2);
return luas;
}
public static void main(String[]args) {
Soal1 mt=new Soal1();
System.out.println(mt.luas_lingkaran(20));
System.exit(0);

}}

*** LUAS LINGKARAN

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modul7;

/**
 *
 * @author pemrograman
 */
import java.io.*;

public class Soal1b {
public double luas_lingkaran(int diameter) {
        int jari = diameter / 2;
        double luas = (3.14*jari*jari);
        return luas;

       
    }
  
    public static void main(String[] args) throws IOException {
         System.out.println("masukkan diameter");
        Soal1 mt = new Soal1();
        BufferedReader o = new BufferedReader(new InputStreamReader(System.in));
        int l_lingkaran = Integer.parseInt(o.readLine());
        int tinggi = 10;
   
        System.out.println("luas lingkaran = "+mt.luas_lingkaran(l_lingkaran));
        System.out.println("tabung = "+mt.luas_lingkaran(l_lingkaran)*tinggi);
        System.out.println("kerucut = "+0.3*mt.luas_lingkaran(l_lingkaran*tinggi));
        System.out.println("Bola = "+1.3*mt.luas_lingkaran(l_lingkaran));
        System.exit(0);


    }
}

*** MENGHITUNG ZIGMA

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modul7;

import javax.swing.JOptionPane;

/**
 *
 * @author pemrograman
 */
public class Soal2 {

    public int ayy(int x, int n) {
        int jumlah = 0;
        for (int j = 1; j <= n; j++) {
            int nilai = x + (2 * j);
            jumlah += nilai;
        }
        return jumlah;
    }

    public static void main(String[] args) {
        int x = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Nilai x : "));
        int n = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Nilai n : "));
        System.out.println("nilai x\t:" + x);
        System.out.println("nilai n\t: " + n);

        Soal2 ayy = new Soal2();
        System.out.println(ayy.ayy(x, n));
    }
}

Comments

Popular posts from this blog

Pengalaman KRS an yang pertama

30 Menit Sesi Akhir

Memasukkan Gambar Pada Eclipse