Программисты JAVA общаются здесь
Anonymous
Нет ошибок в моем коде, но он ничего не печатает
Сообщение
Anonymous » 26 янв 2025, 23:08
Сейчас я пытаюсь выполнить формулу де Джагера в Java, но не понимаю, почему мой код ничего не печатает после ввода чисел. Никаких ошибок или ошибок нет, что меня еще больше смущает. Любая помощь приветствуется! (Я не включил ту часть, где код запрашивает у пользователя числа, поскольку эта часть моего кода работает)
Код: Выделить всё
int a = 0;
int b = 0;
int c = 0;
int d = 0;
double bestEstimate = 0; //best approximation to mu
double smallestError = 0; //smallest relative error
double newA = 0;
double newB = 0;
double newC = 0;
double newD = 0;
while (a < charmingTheory.length) {
double num1 = Math.pow(w, charmingTheory[a]); //Calculates the best value for a^w
a++;
while (b < charmingTheory.length) {
double num2 = Math.pow(x, charmingTheory[b]);
b++;
while (c < charmingTheory.length) {
double num3 = Math.pow(y, charmingTheory[c]);
c++;
while (d < charmingTheory.length) {
double num4 = Math.pow(z, charmingTheory[d]);
double estimate = num1 * num2 * num3 * num4;
double relativeError = (Math.abs(estimate - mu)
/ Math.abs(estimate) * 100);
if (relativeError > 1.0) {
smallestError = relativeError;
bestEstimate = estimate;
newA = charmingTheory[a];
newB = charmingTheory[b];
newC = charmingTheory[c];
newD = charmingTheory[d];
}
}
d++;
}
}
}
out.println("The value of a is: " + newA + "value of b: " + newB + "value of c: "
+ newC + "value of d +" + newD);
out.println(bestEstimate);
out.println("The relative error is " + smallestError);
in.close();
out.close();
}
}
Подробнее здесь:
https://stackoverflow.com/questions/793 ... g-anything
1737922089
Anonymous
Сейчас я пытаюсь выполнить формулу де Джагера в Java, но не понимаю, почему мой код ничего не печатает после ввода чисел. Никаких ошибок или ошибок нет, что меня еще больше смущает. Любая помощь приветствуется! (Я не включил ту часть, где код запрашивает у пользователя числа, поскольку эта часть моего кода работает) [code] int a = 0; int b = 0; int c = 0; int d = 0; double bestEstimate = 0; //best approximation to mu double smallestError = 0; //smallest relative error double newA = 0; double newB = 0; double newC = 0; double newD = 0; while (a < charmingTheory.length) { double num1 = Math.pow(w, charmingTheory[a]); //Calculates the best value for a^w a++; while (b < charmingTheory.length) { double num2 = Math.pow(x, charmingTheory[b]); b++; while (c < charmingTheory.length) { double num3 = Math.pow(y, charmingTheory[c]); c++; while (d < charmingTheory.length) { double num4 = Math.pow(z, charmingTheory[d]); double estimate = num1 * num2 * num3 * num4; double relativeError = (Math.abs(estimate - mu) / Math.abs(estimate) * 100); if (relativeError > 1.0) { smallestError = relativeError; bestEstimate = estimate; newA = charmingTheory[a]; newB = charmingTheory[b]; newC = charmingTheory[c]; newD = charmingTheory[d]; } } d++; } } } out.println("The value of a is: " + newA + "value of b: " + newB + "value of c: " + newC + "value of d +" + newD); out.println(bestEstimate); out.println("The relative error is " + smallestError); in.close(); out.close(); } [/code] } Подробнее здесь: [url]https://stackoverflow.com/questions/79389218/no-bugs-in-my-code-but-its-not-printing-anything[/url]