Compare commits

...

4 Commits

Author SHA1 Message Date
cba4d08315 Vorlesung 3 / Aufgabe 4 2024-05-10 08:14:31 +02:00
4257cab1fa Vorlesung 3 / Aufgabe 3 2024-05-10 08:09:58 +02:00
d64c33dfe5 Vorlesung 3 / Aufgabe 2 2024-05-10 08:01:49 +02:00
dc781ca0bd Vorlesung 3 / Aufgabe 1 2024-05-09 15:16:52 +02:00
7 changed files with 79 additions and 55 deletions

View File

@ -1,5 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
System.out.println("Hallo Welt");
}
}

View File

@ -1,23 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
// Die drei Zahlen für die Prüfung definieren.
int a = 3;
int b = 4;
int c = 5;
// Die Zahlen überprüfen und das Ergebnis ausgeben.
System.out.println("Werte entsprechen dem Satz des Pythagoras: " + (check(a,b,c) ? "Ja" : "Nein"));
}
/**
* Prüfen ob die angegebenen Zahlen dem Satz des Pythagoras entsprechen.
* @param a Die erste Zahl (a).
* @param b Die zweite Zahl (b).
* @param c Das Ergebnis (c).
* @return Status ob die angegebenen Zahlen dem Satz des Pythagoras entsprechen.
*/
public static boolean check(int a, int b, int c) {
return (a*a + b*b == c*c) ? true : false;
}
}

View File

@ -1,25 +0,0 @@
class Aufgabe {
public static void main(String[] args) {
int i = 5;
int j = 3;
boolean b = false;
/*
* a.) (!((i<j) && b)) - boolean (true)
* b.) i/j - int (1)
* c.) (float) (i/j) - float (1.0)
* d.) (float) i/j - float (1.6)
* e.) (float) i / (float) j - float (1.6)
* f.) ((i++ == 5) || (--i == 5)) - boolean (true)
* g.) ((i++ == 5) | (--i == 5)) - int (1)
*/
System.out.println("a.) " + (!((i<j) && b)));
System.out.println("b.) " + (i/j));
System.out.println("c.) " + (float) (i/j));
System.out.println("d.) " + ((float) i/j));
System.out.println("e.) " + ((float) i / (float) j));
System.out.println("f.) " + (((i++ == 5) || (--i == 5))));
System.out.println("g.) " + (((i++ == 5) | (--i == 5))));
}
}

View File

@ -0,0 +1,12 @@
package VL03.Aufgabe01;
/**
* Vorlesung 3 / Aufgabe 1
*
* @author Sebastian Brosch
*/
public class Aufgabe01 {
public static void main(String[] args) {
System.out.println("Hallo Welt");
}
}

View File

@ -1,16 +1,29 @@
class Aufgabe {
package VL03.Aufgabe02;
/**
* Vorlesung 3 / Aufgabe 2
*
* @author Sebastian Brosch
*/
public class Aufgabe02 {
public static void main(String[] args) {
int a1 = 2;
int a2 = 4;
int a3 = 6;
System.out.printf("a1: %d, a2: %d, a3: %d\n\n", a1, a2, a3);
System.out.println("a.) Arithmetisches Mittel: " + ((a1 + a2 + a3) / 3));
System.out.println("b.) Ist " + a1 + " < " + a2 + " < " + a3 + "? " + (a1 < a2 && a2 < a3 ? "Ja" : "Nein"));
System.out.println("c.) Ist " + a1 + " ein ganzzahliges Vielfaches von " + a2 + "? " + (a1 % a2 == 0 ? "Ja" : "Nein"));
System.out.println("c.) Ist " + a1 + " ein Vielfaches von " + a2 + "? " + (a1 % a2 == 0 ? "Ja" : "Nein"));
System.out.println("d.) " + a3 + " invertiert: " + (~a3));
a3 = Integer.MAX_VALUE;
System.out.println("e.) Größter positiver Integer-Wert: " + (a3));
System.out.println("f.) Größter postiver Integer-Wert + 1: " + (a3 + 1));
a2 = 0xFFFFFFFF;
a2 = ~(a3 << a2);
System.out.println("g.) a2 (0xFFFFFFFF) nach a3 umwandeln: " + a2);
}
}

View File

@ -0,0 +1,30 @@
package VL03.Aufgabe03;
/**
* Vorlesung 3 / Aufgabe 3
*
* @author Sebastian Brosch
*/
public class Aufgabe03 {
public static void main(String[] args) {
int a = 3;
int b = 4;
int c = 5;
System.out.printf("a: %d, b: %d, c: %d\n", a, b, c);
System.out.println("Werte entsprechen dem Satz des Pythagoras: " + (check(a, b, c) ? "Ja" : "Nein"));
}
/**
* Method to check three numbers against the pythagorean theorem.
*
* @param a The first number (a in formula).
* @param b The second number (b in formula).
* @param c The result of the theorem (c in formula).
* @return The state whether the three numbers are matching the pythagorean
* theorem.
*/
public static boolean check(int a, int b, int c) {
return (a * a + b * b == c * c) ? true : false;
}
}

View File

@ -0,0 +1,22 @@
package VL03.Aufgabe04;
/**
* Vorlesung 3 / Aufgabe 4
*
* @author Sebastian Brosch
*/
public class Aufgabe04 {
public static void main(String[] args) {
int i = 5;
int j = 3;
boolean b = false;
System.out.println("a.) " + (!((i < j) && b)));
System.out.println("b.) " + (i / j));
System.out.println("c.) " + (float) (i / j));
System.out.println("d.) " + ((float) i / j));
System.out.println("e.) " + ((float) i / (float) j));
System.out.println("f.) " + (((i++ == 5) || (--i == 5))));
System.out.println("g.) " + (((i++ == 5) | (--i == 5))));
}
}