Upload files to "Aufgaben"
This commit is contained in:
BIN
Aufgaben/JO04_Mehrere Klassen2 - Vererbung.pdf
Normal file
BIN
Aufgaben/JO04_Mehrere Klassen2 - Vererbung.pdf
Normal file
Binary file not shown.
BIN
Aufgaben/JO05_Vererbung_Übung.pdf
Normal file
BIN
Aufgaben/JO05_Vererbung_Übung.pdf
Normal file
Binary file not shown.
BIN
Aufgaben/JO06_Array und Arraylist.pdf
Normal file
BIN
Aufgaben/JO06_Array und Arraylist.pdf
Normal file
Binary file not shown.
38
Aufgaben/Noten.java
Normal file
38
Aufgaben/Noten.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Scanner;
|
||||||
|
public class Noten{
|
||||||
|
public static void main(String args[]){
|
||||||
|
double[] noten = new double[6];
|
||||||
|
double summe = 0;
|
||||||
|
|
||||||
|
// Noten eingeben und prüfen
|
||||||
|
Scanner eingabe = new Scanner(System.in);
|
||||||
|
|
||||||
|
for (int i = 0; i < noten.length; i++) {
|
||||||
|
System.out.print("Bitte Note Nr. " + (i+1) + " eingeben: ");
|
||||||
|
double note = eingabe.nextDouble();
|
||||||
|
if(note >= 1 && note <= 6){
|
||||||
|
noten[i] = note;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Die Note muss zwischen 1 und 6 liegen!");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
} // end of for
|
||||||
|
|
||||||
|
|
||||||
|
// Noten sortiert ausgeben
|
||||||
|
Arrays.sort(noten);
|
||||||
|
|
||||||
|
for (int i = 0; i < noten.length; i++) {
|
||||||
|
System.out.println("Note Nr. " + (i+1) + " lautet " + noten[i]);
|
||||||
|
summe += noten[i];
|
||||||
|
} // end of for
|
||||||
|
|
||||||
|
// Durchschnitt aus Summe der Noten und Array-Größe berechnen
|
||||||
|
double durchschnitt = summe / noten.length;
|
||||||
|
|
||||||
|
System.out.println("Der Durchschnitt ist " + durchschnitt);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user