Upload files to "Aufgaben/PTP_1"
This commit is contained in:
36
Aufgaben/PTP_1/J05A2.java
Normal file
36
Aufgaben/PTP_1/J05A2.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
public class J05A2 {
|
||||||
|
public static void main(String args[]){
|
||||||
|
int zahlen[] = {13, 9, 67, 42, 101, 99, 97, 112, 83, 5, 78};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// a)
|
||||||
|
for (int i = 0; i < zahlen.length; i++) {
|
||||||
|
System.out.println("Zahl Nr. " + (i+1) + " lautet " + zahlen[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int zahl: zahlen ) {
|
||||||
|
System.out.println(zahl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// b)
|
||||||
|
for (int i = 0; i < zahlen.length; i++) {
|
||||||
|
if (i < zahlen.length - 1) {
|
||||||
|
System.out.print(zahlen[i] + " - ");
|
||||||
|
} else {
|
||||||
|
System.out.println(zahlen[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// c)
|
||||||
|
Arrays.sort(zahlen);
|
||||||
|
for (int zahl: zahlen ) {
|
||||||
|
System.out.println(zahl);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Kleinstes Element: " + zahlen[0]);
|
||||||
|
System.out.println("Größtes Element: " + zahlen[zahlen.length - 1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Aufgaben/PTP_1/Kraftstoffverbrauch.java
Normal file
13
Aufgaben/PTP_1/Kraftstoffverbrauch.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
public class Kraftstoffverbrauch {
|
||||||
|
public static void main(String args[]){
|
||||||
|
double gefahreneKm = 437;
|
||||||
|
double verbrauchterKraftstoff = 28.9;
|
||||||
|
|
||||||
|
double verbrauch100Km = (verbrauchterKraftstoff / gefahreneKm) * 100;
|
||||||
|
|
||||||
|
System.out.println("Gefahrene KM: " + gefahreneKm);
|
||||||
|
System.out.println("Verbrauchter Kraftstoff: " + verbrauchterKraftstoff +" Liter");
|
||||||
|
System.out.println("Verbrauch je 100km: " + verbrauch100Km + " Liter je 100Km");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Aufgaben/PTP_1/Lottozahlen.java
Normal file
60
Aufgaben/PTP_1/Lottozahlen.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Lottozahlen {
|
||||||
|
public static void main(String args[]){
|
||||||
|
int lottozahlen[] = {17, 9, 39, 23, 41, 6};
|
||||||
|
//Scanner eingabe = new Scanner(System.in);
|
||||||
|
|
||||||
|
/*
|
||||||
|
int lottozahlen[] = new int[6];
|
||||||
|
lottozahlen[0] = eingabe.nextInt();
|
||||||
|
lottozahlen[1] = eingabe.nextInt();
|
||||||
|
lottozahlen[2] = eingabe.nextInt();
|
||||||
|
lottozahlen[3] = eingabe.nextInt();
|
||||||
|
lottozahlen[4] = eingabe.nextInt();
|
||||||
|
lottozahlen[5] = eingabe.nextInt();
|
||||||
|
*/
|
||||||
|
|
||||||
|
System.out.println("Die heutigen Lottozahlen sind " + lottozahlen);
|
||||||
|
System.out.println("Es sind " + lottozahlen.length + " Lottozahlen gezogen worden.");
|
||||||
|
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
|
||||||
|
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
|
||||||
|
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
|
||||||
|
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
|
||||||
|
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
|
||||||
|
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
|
||||||
|
|
||||||
|
System.out.println("- - - - - - - - - - - - - - - - - - -");
|
||||||
|
|
||||||
|
//lottozahlen[3] = 32;
|
||||||
|
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
|
||||||
|
|
||||||
|
System.out.println("- - - - - - - - - - - - - - - - - - -");
|
||||||
|
|
||||||
|
for (int i = 0; i < lottozahlen.length; i++) {
|
||||||
|
System.out.println("Lottozahl Nr. " + (i + 1) + " lautet " + lottozahlen[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("- - - - - - - - - - - - - - - - - - -");
|
||||||
|
|
||||||
|
for (int zahl: lottozahlen) {
|
||||||
|
System.out.println("Die aktuelle Lottozahl lautet: " + zahl);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("- - - - - - - - - - - - - - - - - - -");
|
||||||
|
|
||||||
|
Arrays.sort(lottozahlen);
|
||||||
|
|
||||||
|
System.out.println("Die erste Lottozahl lautet: " + lottozahlen[0]);
|
||||||
|
System.out.println("Die zweite Lottozahl lautet: " + lottozahlen[1]);
|
||||||
|
System.out.println("Die dritte Lottozahl lautet: " + lottozahlen[2]);
|
||||||
|
System.out.println("Die vierte Lottozahl lautet: " + lottozahlen[3]);
|
||||||
|
System.out.println("Die fünfte Lottozahl lautet: " + lottozahlen[4]);
|
||||||
|
System.out.println("Die sechste Lottozahl lautet: " + lottozahlen[5]);
|
||||||
|
|
||||||
|
System.out.println("- - - - - - - - - - - - - - - - - - -");
|
||||||
|
|
||||||
|
System.out.println("Die heutigen Lottozahlen sind: " + Arrays.toString(lottozahlen));
|
||||||
|
}
|
||||||
|
}
|
||||||
5
Aufgaben/PTP_1/MeinErstesProgramm.java
Normal file
5
Aufgaben/PTP_1/MeinErstesProgramm.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
public class MeinErstesProgramm{
|
||||||
|
public static void main(String args[]){
|
||||||
|
System.out.println("Hallo Welt!");
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Aufgaben/PTP_1/lottoArray.java
Normal file
10
Aufgaben/PTP_1/lottoArray.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import java.util.Arrays;
|
||||||
|
public class lottoArray{
|
||||||
|
public static void main(String args[]){
|
||||||
|
int lottozahlen[] = {17, 9, 39, 23, 41, 6};
|
||||||
|
System.out.println("Anzahl Elemente im Array: " + lottozahlen.length);
|
||||||
|
System.out.println("Komplettes Array: " + Arrays.toString(lottozahlen));
|
||||||
|
Arrays.sort(lottozahlen);
|
||||||
|
System.out.println("Komplettes Array: " + Arrays.toString(lottozahlen));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user