Created
May 4, 2020 09:20
-
-
Save KaratekHD/c21c784130403d07dec3e4c32737bcb7 to your computer and use it in GitHub Desktop.
Beispielhaftes Java Programm zum Lösen von Aufgaben mithilfe des Satzes des Pythagoras.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.karatek.randomstuff; | |
public class pythagoras { | |
public static void main(String[] args) { | |
katheteb(); | |
} | |
public static void hypothenuse() { | |
String unit = "mm"; | |
double a = 5; | |
double b = 4; | |
double c; | |
System.out.println("a = " + a + unit); | |
System.out.println("b = " + b + unit); | |
a = a * a; | |
b = b * b; | |
c = a + b; | |
c = Math.sqrt(c); | |
System.out.println("a * a = " + a + unit); | |
System.out.println("b * b = " + b + unit); | |
System.out.println("c ist die Wurzel aus a * a + b * b"); | |
c = c * 100; | |
c = Math.round(c); | |
c = c / 100; | |
System.out.println("c = " + c + unit); | |
System.out.println(c + unit); | |
} | |
public static void katheteb() { | |
String unit = "m"; | |
double a = 65; | |
double b; | |
double c = 97; | |
System.out.println("a = " + a + unit); | |
System.out.println("c = " + c + unit); | |
a = a * a; | |
c = c * c; | |
b = c - a; | |
b = Math.sqrt(b); | |
System.out.println("a * a = " + a + unit); | |
System.out.println("c * c = " + c + unit); | |
System.out.println("b ist die Differenz aus a*a und c*c."); | |
b = b * 100; | |
b = Math.round(b); | |
b = b / 100; | |
System.out.println("b = " + b + unit); | |
System.out.println(b + unit); | |
} | |
public static void kathetea() { | |
String unit = "km"; | |
double a; | |
double b = 35; | |
double c = 37; | |
System.out.println("b = " + b + unit); | |
System.out.println("c = " + c + unit); | |
b = b * b; | |
c = c * c; | |
a = c - b; | |
a = Math.sqrt(a); | |
System.out.println("b * b = " + b + unit); | |
System.out.println("c * c = " + c + unit); | |
System.out.println("b ist die Differenz aus b*b und c*c."); | |
a = a * 100; | |
a = Math.round(a); | |
a = a / 100; | |
System.out.println("a = " + a + unit); | |
System.out.println(a + unit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment