!!! Das Problem habe ich gerade selber gelöst !!!
Die Syntax von "Math.pow" war falsch (jetzt richtig, siehe Fettschrift).
Hi,
leider habe ich jetzt ein anderes Problem. Und zwar bei folgendem Code tritt dieser Fehler auf:
pow(double,double) in java.lang.Math cannot be applied to (double)
Hier der gesamte Code:
import java.lang.Math;
public class CZinsen_mit_Schleife
{
public static void main(String[] args)
{
double endkapital;
double endkapital_ohne;
int laufzeit = 5;
double zinsen = 3.5;
double startkapital = 15000;
int i;
for (i = 1; i <= laufzeit; i++)
{
endkapital = zins_berechnen(startkapital,zinsen, i);
endkapital_ohne = ohne_zins_berechnen(startkapital,zinsen, i);
System.out.println("Der Endbetrag mit Zinsen nach " + i + " Jahren: " + (int) endkapital);
System.out.println("Der Endbetrag ohne Zinsen nach " + i + " Jahren: " + (int) endkapital_ohne);
}
}
// Ertrag mit Zinsen
public static double zins_berechnen(double startkapital, double zinssatz, int laufzeit)
{
double endkapital;
// Berechnung des Endkapitals
endkapital = startkapital * Math.pow((1 + zinssatz / 100), (double) laufzeit);
return endkapital;
}
// Ertrag ohne Zinsen
public static double ohne_zins_berechnen(double startkapital, double zinssatz, int laufzeit)
{
double endkapital;
// Berechnung des Endkapitals
endkapital = startkapital * Math.pow(1 + zinssatz / 100 * (double) laufzeit[B], 1[/B]);
return endkapital;
}
}
Ich habe schon ein bisschen gegoogelt, aber leider nix gefunden. Für mich ist der Code auch soweit einleuchtend. Was habe ich falsch gemacht? :confused: