Vorlesung 3 / Aufgabe 3
This commit is contained in:
parent
d64c33dfe5
commit
4257cab1fa
@ -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;
|
||||
}
|
||||
}
|
30
VL03/Aufgabe03/Aufgabe03.java
Normal file
30
VL03/Aufgabe03/Aufgabe03.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user