Menghitung Nilai Fungsi di Java

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

package javaapplication25;

/**
*
* @author ANGGA
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

 

// masukkan nilai x

System.out.println(fungsi(-2));
System.out.println(fungsi(4));
System.out.println(rata2(fungsi(-2),fungsi(4)));

System.out.println();

}

public static double fungsi(double x){

// disini untuk merubah fungsi
double hasil=Math.pow(x, 4)+3*Math.pow(x, 3)+6*Math.pow(x, 2)-7*x;
return hasil;
}

public static double rata2(double x, double y){
double rata2=(x+y)/2;
return rata2;
}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google 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 )

Connecting to %s