Fungsi untuk menghitung operasi pangkat 

import java.util.Scanner;
public class pow {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double angka, pangkat, hasil;
System.out.print(“Angka : “);
angka = in.nextDouble();
System.out.print(“Pangkat : “);
pangkat = in.nextDouble();
hasil = Math.pow(angka, pangkat);
System.out.println(“Hasil Pangkat = ” + hasil);
}
}
.
Mencari nilai akar sebuah angka 
import java.util.Scanner;
public class sqrt {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double angka, akar;
System.out.print(“Angka : “);
angka = in.nextDouble();
akar = Math.sqrt(angka);
System.out.println(“Hasil Akar = ” + akar);
}
}
.
Menghitung nilai logaritma basis 10
import java.util.Scanner;
public class log10 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double angka = in.nextInt();
double hasil = Math.log10(angka);
System.out.println(hasil);
}
}
.
Mencari nilai sin
import java.util.Scanner;
public class sin {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double angka = in.nextDouble();
double hasil = Math.sin(angka);
System.out.println(hasil);
}
}
.

Mencari nilai maksimum dari 2 buah angka 
import java.util.Scanner;
public class max {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A = in.nextInt();
int B = in.nextInt();
System.out.println(Math.max(A, B));
}
}
.
Mencari nilai minimum dari 2 buah angka 
import java.util.Scanner;
public class min {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A = in.nextInt();
int B = in.nextInt();
System.out.println(Math.min(A, B));
}
}
.
Membuat nilai absolute (Nilai Mutlak) 
import java.util.Scanner;
public class abs {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int A = in.nextInt();
System.out.println(Math.abs(A));
}
}
.
Pembulatan keatas pada sebuah bilangan decimal 
public class ceil {
public static void main(String[] args) {
double angka = 3.45;
System.out.println(Math.ceil(angka));
System.out.println(Math.floor(angka));
}
}

.

About Awan79 Exactly !! :)

I'm ordinary man :)

Tinggalkan comment ya :)

Please log in using one of these methods to post your comment:

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