30.01.25
This commit is contained in:
parent
c274b66630
commit
0b5ce2cc00
7 changed files with 85 additions and 1 deletions
18
src/de/dhbwka/java/exercise/control/AddUp.java
Normal file
18
src/de/dhbwka/java/exercise/control/AddUp.java
Normal 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);
|
||||
}
|
||||
}
|
13
src/de/dhbwka/java/exercise/control/Deers.java
Normal file
13
src/de/dhbwka/java/exercise/control/Deers.java
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
16
src/de/dhbwka/java/exercise/control/LeapYear.java
Normal file
16
src/de/dhbwka/java/exercise/control/LeapYear.java
Normal 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.");
|
||||
}
|
||||
}
|
||||
}
|
12
src/de/dhbwka/java/exercise/control/MultiplicationTable.java
Normal file
12
src/de/dhbwka/java/exercise/control/MultiplicationTable.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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) {
|
13
src/de/dhbwka/java/exercise/control/ShoeSize.java
Normal file
13
src/de/dhbwka/java/exercise/control/ShoeSize.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
12
src/de/dhbwka/java/exercise/control/TemperatureTable.java
Normal file
12
src/de/dhbwka/java/exercise/control/TemperatureTable.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue