This commit is contained in:
Dominik 2025-01-30 10:40:43 +01:00
parent c274b66630
commit 0b5ce2cc00
7 changed files with 85 additions and 1 deletions

View file

@ -0,0 +1,18 @@
package de.dhbwka.java.exercise.control;
public class AddUp {
public static void main(String[] args) {
java.util.Scanner scan = new java.util.Scanner(System.in);
int sum = 0;
do {
System.out.print("Zahl eingeben (<0 für Abbruch): ");
int number = scan.nextInt();
if (number < 0) {
break;
}
sum += number;
} while (true);
scan.close();
System.out.println("Summe: " + sum);
}
}

View file

@ -0,0 +1,13 @@
package de.dhbwka.java.exercise.control;
public class Deers {
public static void main(String[] args) {
int deers = 200;
int i = 0;
while (deers < 300) {
i++;
deers = (int) (deers * 1.1) - 15;
System.out.println("Nach " + i + " Jahren: " + deers + " Rehe");
}
}
}

View file

@ -0,0 +1,16 @@
package de.dhbwka.java.exercise.control;
public class LeapYear {
public static void main(String[] args) {
java.util.Scanner scan = new java.util.Scanner(System.in);
System.out.print("Welches Jahr soll auf Schaltjahr geprüft werden? ");
int year = scan.nextInt();
scan.close();
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
System.out.println(year + " ist ein Schaltjahr.");
} else {
System.out.println(year + " ist kein Schaltjahr.");
}
}
}

View file

@ -0,0 +1,12 @@
package de.dhbwka.java.exercise.control;
public class MultiplicationTable {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.printf("%4d", i * j);
}
System.out.println();
}
}
}

View file

@ -1,4 +1,4 @@
package de.dhbwka.java.exercise.control_structures;
package de.dhbwka.java.exercise.control;
public class Quadratics {
public static void main(String[] args) {

View file

@ -0,0 +1,13 @@
package de.dhbwka.java.exercise.control;
public class ShoeSize {
public static void main(String[] args) {
System.out.println("Zentimeter | Schuhgröße");
System.out.println("------------------------+-----------");
for (int ShoeSize = 30; ShoeSize <= 45; ShoeSize++) {
double centimeterMin = (ShoeSize - 1) / 1.5;
double centimeterMax = ShoeSize / 1.5;
System.out.printf("%10.2f - %10.2f | %10d\n", centimeterMin, centimeterMax, ShoeSize);
}
}
}

View file

@ -0,0 +1,12 @@
package de.dhbwka.java.exercise.control;
public class TemperatureTable {
public static void main(String[] args) {
System.out.println("Fahrenheit | Celsius");
System.out.println("-----------+--------");
for (int fahrenheit = 0; fahrenheit <= 300; fahrenheit += 20) {
double celsius = (fahrenheit - 32) * 5.0 / 9.0;
System.out.printf("%10d | %6.1f\n", fahrenheit, celsius);
}
}
}