Mittelwert hinzugefügt

This commit is contained in:
Joel Baldauf
2020-12-18 10:39:46 +01:00
parent f464f88a6f
commit 7da8a1f47c
5 changed files with 77 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+1
View File
@@ -0,0 +1 @@
/bin/
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mittelwert</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
+41
View File
@@ -0,0 +1,41 @@
import java.util.Scanner; //1
public class Mittelwert {
public static double verarbeitung(double pZahl1, double pZahl2) {
double ergebnis = (pZahl1 + pZahl2) / 2.0;
return ergebnis;
}
public static void main(String[] args) {
Scanner meinScanner = new Scanner(System.in); //2
// Deklaration der Variablen
double zahl1;
double zahl2;
double mittelwert;
// (E) "Eingabe"
// Werte für x und y festlegen:
System.out.print("Wie lautet der erste Wert? ");
zahl1 = meinScanner.nextDouble(); //3
System.out.print("Wie lautet der zweite Wert? ");
zahl2 = meinScanner.nextDouble(); //3
// (V) Verarbeitung
// Mittelwert von x und y berechnen:
// ================================
// mittelwert = (zahl1 + zahl2) / 2.0;
mittelwert = verarbeitung(zahl1, zahl2);
// (A) Ausgabe
// Ergebnis auf der Konsole ausgeben:
// =================================
System.out.printf("Der Mittelwert von %.2f und %.2f ist %.2f\n", zahl1, zahl2, mittelwert);
}
}