VL-Programmieren/VL03/Aufgabe03/Aufgabe03.java

31 lines
820 B
Java

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;
}
}