Editing Java - Einführung
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== Tag 1== | == Tag 1== | ||
=== Variablen und Datentpyen === | |||
public class aboutMe { | |||
public static void main(String[] args) { | |||
byte age = 34; | |||
String firstName = "Adel"; | |||
String lastName = "Golnazari"; | |||
char gender = 'M'; | |||
String birthDay = "10.01.1989"; | |||
double pointAverage = 1.5; | |||
boolean married = false; | |||
System.out.println("Vor und Nachname: " + firstName + " " + lastName + "\n Alter: " + age + "\n Geschlecht: " + gender + "\n Geburtsdatum: " + birthDay + "\n Notendurchschnitt: " + pointAverage + "\n Verheiratet: " + married); | |||
} | |||
} | |||
==== Aufgabe 1.2 - Einfache Rechenaufgaben ==== | |||
public class Calculate { | |||
public static void main(String[] args) { | |||
int number1 = 150; | |||
int number2 = 50; | |||
int summe = number1 + number2; | |||
int difference = number1 - number2; | |||
double numberA = 7.75 ; | |||
double numberB = 5.55; | |||
double summeDouble = numberA + numberB; | |||
double differenceDouble = numberA - numberB; | |||
System.out.println(number1 + " + " + number2 + " = " + summe + "\n" + number1 + " - " + number2 + " = " + difference); | |||
System.out.print(numberA + " + " + numberB + " = " + summeDouble + "\n" + numberA + " - " + numberB + " = " + differenceDouble); | |||
} | |||
} | |||
==== Aufgabe 1.3 - Arbeiten mit Strings [🤓 Advanced] ==== | |||
public class Calculate { | |||
public static void main(String[] args) { | |||
String helloWorld = " Hello World! "; | |||
int length = 0; | |||
for (int i = 0; i < helloWorld.length(); i++) { | |||
i++; | |||
length = i; | |||
} | |||
System.out.println(helloWorld + "Länge: " + length); | |||
System.out.printf("%S", helloWorld); | |||
helloWorld = helloWorld.toLowerCase(); | |||
System.out.println(helloWorld); | |||
helloWorld = "Hello Codersbay! "; | |||
System.out.println(helloWorld); | |||
for (int i = 0; i <= 15; i++) { | |||
System.out.println(helloWorld); | |||
} | |||
} | |||
} | |||
===Variables and Datatypes=== | ===Variables and Datatypes=== |