Browse Source

Leibniz Formel

remotes/origin/develop
fdai7460 2 years ago
parent
commit
6883c4f59a
  1. 20
      src/main/java/src/TasksFrame.java
  2. 15
      src/test/java/src/TasksFrameTest.java

20
src/main/java/src/TasksFrame.java

@ -68,8 +68,28 @@ public class TasksFrame extends JFrame {
setup5ModList(1, 20); setup5ModList(1, 20);
setupLeibnizR(1000);
}
public double setupLeibnizR(int t) {
double sum=0;
for(int i=0;i<t;i++){
sum += Math.pow(-1,i)/((2*i)+1);
}
JPanel jPanel = setupPanel("Leibniz F. von 0 bis" + t);
JLabel summe = new JLabel();
summe.setVisible(true);
summe.setText(String.valueOf(sum));
summe.setBounds(10,50,100,30);
jPanel.add(summe);
return sum;
} }
private ArrayList<Integer> setup5ModList(int from, int to) { private ArrayList<Integer> setup5ModList(int from, int to) {
ArrayList<Integer> mods = new ArrayList<>(); ArrayList<Integer> mods = new ArrayList<>();

15
src/test/java/src/TasksFrameTest.java

@ -0,0 +1,15 @@
package src;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class TasksFrameTest {
@Test
void setupLeibnizR() {
TasksFrame tasksFrame = new TasksFrame();
double x = tasksFrame.setupLeibnizR(100000);
assertEquals(Math.PI/4, x, 0.00001, "Die Werte sind unterschiedlich. Soll: 0.785 Ist:" +x);
}
}
Loading…
Cancel
Save