Vorlesung 4 / Aufgabe 1
This commit is contained in:
parent
7b69a0c9dc
commit
98e7893343
@ -1,21 +0,0 @@
|
||||
class Aufgabe {
|
||||
public static void main(String[] args) {
|
||||
final int MAXIMUM = 10;
|
||||
|
||||
System.out.println("Alle geraden Zahlen zwischen 1 und " + MAXIMUM + " (aufsteigend):");
|
||||
|
||||
for(int i = 1; i <= MAXIMUM; i++) {
|
||||
if(i % 2 == 0) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Alle ungeraden Zahlen zwischen 1 und " + MAXIMUM + " (absteigend):");
|
||||
|
||||
for(int i = MAXIMUM; i >= 1; i--) {
|
||||
if(i % 2 == 1) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
VL04/Aufgabe01/Aufgabe01.java
Normal file
26
VL04/Aufgabe01/Aufgabe01.java
Normal file
@ -0,0 +1,26 @@
|
||||
package VL04.Aufgabe01;
|
||||
|
||||
/**
|
||||
* Vorlesung 4 / Aufgabe 1
|
||||
*
|
||||
* @author Sebastian Brosch
|
||||
*/
|
||||
public class Aufgabe01 {
|
||||
public static void main(String[] args) {
|
||||
final int MAXIMUM = 25;
|
||||
|
||||
System.out.printf("\nGerade Zahlen zwischen 1 und %d:\n", MAXIMUM);
|
||||
|
||||
for (int i = 1; i <= MAXIMUM; i++) {
|
||||
if (i % 2 == 0)
|
||||
System.out.printf("%d\n", i);
|
||||
}
|
||||
|
||||
System.out.printf("\nUngerade Zahlen zwischen 1 und %d:\n", MAXIMUM);
|
||||
|
||||
for (int j = 1; j <= MAXIMUM; j++) {
|
||||
if (j % 2 == 1)
|
||||
System.out.printf("%d\n", j);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user