Browse Source

Zahl Pi Rechner

remotes/origin/develop
fdai7460 2 years ago
parent
commit
b942db1070
  1. 8
      src/main/java/src/TasksFrame.java
  2. 4
      src/test/java/src/TasksFrameTest.java

8
src/main/java/src/TasksFrame.java

@ -79,7 +79,7 @@ public class TasksFrame extends JFrame {
setup5ModList(1, 20);
setupLeibnizR(1000);
setupPI(100000);
setupEulerschePhiFunk();
@ -822,16 +822,16 @@ public class TasksFrame extends JFrame {
return mods;
}
public double setupLeibnizR(int t) {
public double setupPI(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);
JPanel jPanel = setupPanel("Zahl Pi, berechnet mit Hilfe von Leibniz F. von 0 bis" + t);
JLabel summe = new JLabel();
summe.setVisible(true);
summe.setText(String.valueOf(sum));
summe.setText(String.valueOf(sum*4));
summe.setBounds(10,50,100,30);
jPanel.add(summe);

4
src/test/java/src/TasksFrameTest.java

@ -9,8 +9,8 @@ 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);
double x = tasksFrame.setupPI(100000);
assertEquals(Math.PI, x*4, 0.0001, "Die Werte sind unterschiedlich. Soll: 0.785 Ist:" +x*4);
}
@Test

Loading…
Cancel
Save