Upload files to "Aufgaben/PTP_1"

This commit is contained in:
2025-07-29 08:26:05 +02:00
parent 2bb8a136ee
commit ac95b23213
5 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
public class Quadratzahlen{
public static void main(String args[]) {
for (int i = 1; i <= 20 ; i++ ) {
int quadrat = i * i;
System.out.println("Die Quadratzahl von " + i + " lautet " + quadrat);
}
}
}

View File

@@ -0,0 +1,11 @@
public class Sparbuch{
public static void main(String args[]){
double guthaben = 1000;
double zinssatz = 1.5/100;
for (int jahr = 1; jahr <= 25 ; jahr++ ) {
guthaben = guthaben + guthaben * zinssatz;
System.out.println("Guthaben im " + jahr + ". Jahr: " + guthaben);
}
}
}

View File

@@ -0,0 +1,21 @@
public class Steigung {
public static void main (String args[]){
// Koordinaten x1 und y1 von Punkt P
// P(x1 | y1)
double x1 = 4;
double y1 = 6;
// Koordinaten x2 und y2 von Punkt Q
// Q(x2 | y2)
double x2 = 2;
double y2 = 1;
// m = (y2 - y1) / (x2 - x1)
double m = (y2 - y1) / (x2 - x1);
System.out.println("P(" + x1 + " | " + y1 + ")");
System.out.println("Q(" + x2 + " | " + y2 + ")");
System.out.println("Steigung zwischen P und Q: " + m);
}
}

View File

@@ -0,0 +1,9 @@
public class Variablen{
public static void main(String args[]){
int zahl = 3;
double zahlD = (double) zahl;
System.out.println("Int: " + zahl + ", Double: " + zahlD);
}
}

View File

@@ -0,0 +1,12 @@
public class VariablenTest{
public static void main(String args[]){
int zaehler = 3;
double zaehlerD = (double) zaehler;
double bruch = zaehler / 3.14;
final double pi = 3.1415;
System.out.println("Zaehler: " + zaehler + ", ZaehlerD: " + zaehlerD);
System.out.println("Bruch: " + bruch + ", Pi: " + pi);
}
}