Difference between revisions of "Java - Einführung"

From Coders.Bay Wiki
Jump to navigation Jump to search
Line 2: Line 2:


=== Variablen und Datentpyen ===
=== Variablen und Datentpyen ===
Aufgabe 1.1 - Erzähl mir etwas über dich
 
==== Aufgabe 1.1 - Erzähl mir etwas über dich ====


Deklariere Variablen für dein Alter, deinen Vornamen, dein Geschlecht, deinen Nachnamen, dein Geburtsdatum, deinen Notendurchschnitt und dafür ob du verheiratet bist oder nicht. Überleg dir gut welchen Datentyp du für welche Variablen am besten verwenden solltest.
Deklariere Variablen für dein Alter, deinen Vornamen, dein Geschlecht, deinen Nachnamen, dein Geburtsdatum, deinen Notendurchschnitt und dafür ob du verheiratet bist oder nicht. Überleg dir gut welchen Datentyp du für welche Variablen am besten verwenden solltest.


Gib alle Variablen mit System.out.println auf der Konsole aus.
Gib alle Variablen mit System.out.println auf der Konsole aus.
==== Aufgabe 1.2 - Einfache Rechenaufgaben ====
Deklariere zwei numerische Variablen mit beliebigen Werten. Errechne deren Summe, Differenz, Produkt und Quotient und gib die Rechnung mit dem Ergebnis mit System.out.println/System.out.printf auf der Konsole aus. Rechne einmal mit ganzzahligen und einmal mit gebrochenen Zahlen!
Bonus: Gib die Kommazahlen schön formatiert auf der Konsole aus.
Eine Ausgabe sollte folgendermaßen aussehen:
Beispiel Ausgabe
138 + 235 = 373
138 - 235 = -97


===Variables and Datatypes===
===Variables and Datatypes===
Exercise 1.1 - Tell me about yourself
 
==== Exercise 1.1 - Tell me about yourself ====


Declare variables to express your age, first name, gender, last name, birthday, average grade and whether you are married or not. Think which datatype is well suited for which variable.
Declare variables to express your age, first name, gender, last name, birthday, average grade and whether you are married or not. Think which datatype is well suited for which variable.


Print all variables to the console with System.out.println
Print all variables to the console with System.out.println
==== Exercise 1.2 - Simple Calculations ====
Declare two numeric variables with arbitary values. Calculate their sum, difference, product and quotient and print the calculation with the result on the console with System.out.println/System.out.printf. Perform all calculations with whole numbers and fractional numbers.
Bonus: Try to limit the decimal places of your calculations with the fractional numbers.
Your output should look like this:
138 + 235 = 373
138 - 235 = -97

Revision as of 15:26, 19 December 2021

Woche 1

Variablen und Datentpyen

Aufgabe 1.1 - Erzähl mir etwas über dich

Deklariere Variablen für dein Alter, deinen Vornamen, dein Geschlecht, deinen Nachnamen, dein Geburtsdatum, deinen Notendurchschnitt und dafür ob du verheiratet bist oder nicht. Überleg dir gut welchen Datentyp du für welche Variablen am besten verwenden solltest.

Gib alle Variablen mit System.out.println auf der Konsole aus.

Aufgabe 1.2 - Einfache Rechenaufgaben

Deklariere zwei numerische Variablen mit beliebigen Werten. Errechne deren Summe, Differenz, Produkt und Quotient und gib die Rechnung mit dem Ergebnis mit System.out.println/System.out.printf auf der Konsole aus. Rechne einmal mit ganzzahligen und einmal mit gebrochenen Zahlen!

Bonus: Gib die Kommazahlen schön formatiert auf der Konsole aus.

Eine Ausgabe sollte folgendermaßen aussehen:

Beispiel Ausgabe

138 + 235 = 373 138 - 235 = -97

Variables and Datatypes

Exercise 1.1 - Tell me about yourself

Declare variables to express your age, first name, gender, last name, birthday, average grade and whether you are married or not. Think which datatype is well suited for which variable.

Print all variables to the console with System.out.println

Exercise 1.2 - Simple Calculations

Declare two numeric variables with arbitary values. Calculate their sum, difference, product and quotient and print the calculation with the result on the console with System.out.println/System.out.printf. Perform all calculations with whole numbers and fractional numbers.

Bonus: Try to limit the decimal places of your calculations with the fractional numbers.

Your output should look like this:

138 + 235 = 373 138 - 235 = -97