Created class Zahlenfilter
This commit is contained in:
commit
d9b999f31d
29
.gitignore
vendored
Normal file
29
.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
11
Softwareengeneering.iml
Normal file
11
Softwareengeneering.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
43
src/Praktikum01/Zahlenfilter.java
Normal file
43
src/Praktikum01/Zahlenfilter.java
Normal file
@ -0,0 +1,43 @@
|
||||
package Praktikum01;
|
||||
|
||||
public class Zahlenfilter {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Zahlenfilter checker = new Zahlenfilter();
|
||||
checker.checkZahlen();
|
||||
}
|
||||
|
||||
|
||||
public void checkZahlen() {
|
||||
for (int i = 1; i <= 200; i++) {
|
||||
checkDurchFuenfTeilbar(i);
|
||||
checkEndetAufNeun(i);
|
||||
checkSummeMitVorgaenger(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDurchFuenfTeilbar(int zahl) {
|
||||
if (zahl % 5 == 0) {
|
||||
System.out.println(zahl + " ist durch 5 teilbar!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkEndetAufNeun(int zahl) {
|
||||
if (zahl % 10 == 9) {
|
||||
System.out.println(zahl + " endet auf 9!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkSummeMitVorgaenger(int zahl) {
|
||||
if (zahl > 1) {
|
||||
int vorgaenger = zahl - 1;
|
||||
int summe = zahl + vorgaenger;
|
||||
if (summe % 3 == 0) {
|
||||
System.out.println(zahl + " und " + vorgaenger + " addiert ergeben " + summe + " und " + summe + " ist durch 3 teilbar.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user