public class Visitenkarte { | public class Visitenkarte { | ||||
public static String name = "Pastors"; | |||||
public static String vorname = "Sarah"; | |||||
public static String beruf = "Student"; | |||||
public static int alter = 21; | |||||
public static String adresse = "90443 Nürnberg, Zufuhrstraße 8"; | |||||
public static String telefonnummer = "0913123453"; | |||||
public String name = "Pastors"; | |||||
public String vorname = "Sarah"; | |||||
public String beruf = "Student"; | |||||
public int alter = 21; | |||||
public String adresse = "90443 Nürnberg, Zufuhrstraße 8"; | |||||
public String telefonnummer = "0913123453"; | |||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
ausgabe(); | |||||
Visitenkarte v = new Visitenkarte(); | |||||
v.ausgabe(); | |||||
System.out.println(v); | |||||
} | } | ||||
public static void ausgabe() { | |||||
public void ausgabe() { | |||||
System.out.println("--------------------------------------"); | System.out.println("--------------------------------------"); | ||||
System.out.println(name + ", " + vorname); | System.out.println(name + ", " + vorname); | ||||
System.out.println(beruf + ", " + alter); | System.out.println(beruf + ", " + alter); | ||||
} | } | ||||
public String toString(){ | public String toString(){ | ||||
return "--------------------------------------\n" + name + ", " + vorname + beruf + ", " + alter + adresse + telefonnummer + "--------------------------------------"; | |||||
return "--------------------------------------\n" + name + ", " + vorname + "\n" + beruf + ", " + alter + "\n" + adresse + "\n" + telefonnummer + "\n" + "--------------------------------------"; | |||||
} | } | ||||
} | } |
public static void main(String[] args) { | public static void main(String[] args) { | ||||
int start = 1; | int start = 1; | ||||
int ende = 200; | int ende = 200; | ||||
for(int i=start; i<=ende; i++){ | |||||
durchFuenfTeilbar(i); | |||||
endetAufNeun(i); | |||||
summeMitVorgaengerDurchDreiTeilbar(i); | |||||
for(int number=start; number<=ende; number++){ | |||||
if (durchFuenfTeilbar(number)==true) { | |||||
System.out.println(number + " ist durch 5 teilbar!"); | |||||
} | |||||
if (endetAufNeun(number)==true) { | |||||
System.out.println(number + " endet auf 9!"); | |||||
} | |||||
if (summeMitVorgaengerDurchDreiTeilbar(number)==true) { | |||||
System.out.println(number + " und " + (number-1) + " addiert ergeben " + (number+(number-1)) + " und " + (number+(number-1)) + " ist durch 3 teilbar"); | |||||
} | |||||
} | } | ||||
} | } | ||||
private static void durchFuenfTeilbar(int i) { | |||||
if(i%5 == 0){ | |||||
System.out.println(i + " ist durch 5 teilbar!"); | |||||
private static boolean durchFuenfTeilbar(int number) { | |||||
if(number%5 == 0){ | |||||
return true; | |||||
} | } | ||||
return false; | |||||
} | } | ||||
private static void endetAufNeun(int i) { | |||||
private static boolean endetAufNeun(int i) { | |||||
if(i%10 == 9){ | if(i%10 == 9){ | ||||
System.out.println(i + " endet auf 9!"); | |||||
return true; | |||||
} | } | ||||
return false; | |||||
} | } | ||||
private static void summeMitVorgaengerDurchDreiTeilbar(int i) { | |||||
if((i+(i-1))%3 == 0){ | |||||
System.out.println(i + " und " + (i-1) + " addiert ergeben " + (i+(i-1)) + " und " + (i+(i-1)) + " ist durch 3 teilbar"); | |||||
private static boolean summeMitVorgaengerDurchDreiTeilbar(int number) { | |||||
if((number+(number-1))%3 == 0){ | |||||
return true; | |||||
} | } | ||||
return false; | |||||
} | } | ||||
} | } |