Ich möchte in folgendes Programm eine cos, sinus und sqrt Funktion einbinden, ist mir aber auch mit "import java.lang.Math" nicht gelungen.
Die Methode hieß bei mir so:
public static native double cos(double x);
Als ich aber den Wert mit System.out.println("cosinus Wert" + x); ausgeben wollte kam folgender Error:
java.lang.UnsatisfiedLinkError: FKT.cos(D)D
Vllt kann mir einer helfen...
Die Methode hieß bei mir so:
public static native double cos(double x);
Als ich aber den Wert mit System.out.println("cosinus Wert" + x); ausgeben wollte kam folgender Error:
java.lang.UnsatisfiedLinkError: FKT.cos(D)D
Vllt kann mir einer helfen...
Code:
// FKT.java, V1.0
//------------------------------------------------------------------------------
import java.util.Locale;
import java.util.Scanner;
import java.util.InputMismatchException;
import java.lang.Math;
//------------------------------------------------------------------------------
public class FKT
{
// Funktion f(x)
//
static double f(double x)
{
return (x * x);
}
// Funktion g(x)
//
static double g(double x)
{
return ((x+2) * (x+2));
}
// Funktion h(x)
//
static double h(double x)
{
return ((x-2.5)*(x-2.5)*(x-2.5) + 2);
}
// Funktion j(x)
//
static double j(double x)
{
return (x * x *x);
}
//----------------------------------------------------------------------------
public static void main(String[] args)
{
final double stopper = 0.0;
double x = stopper+1.0, y,y1,y2,y3;
Scanner sc = new Scanner(System.in);
sc.useLocale(Locale.UK); // wg. Dezimalpunkt statt Dezimalkomma!
do
{
// hole double-Wert x von der Tastatur;
//
System.out.print("\ndouble-Wert x (0=Stop) ? ");
try
{
x = sc.nextDouble();
// Aufruf der Funktion f mit dem Argument x:
//
System.out.println(" X | " + " |F(X) ");
y = f(x);
System.out.println(" " + x + " " + y);
y1 = g(x);
System.out.println(" " + x + " " + y1);
y2 = h(x);
System.out.println(" " + x + " " + y2);
y3 = j(x);
System.out.println(" " + x + " " + y3);
}
catch(InputMismatchException ex)
{
System.err.println("*** Falsche Eingabe!");
}
}
while (x != stopper);
}
}
//------------------------------------------------------------------------------
//<>