summaryrefslogtreecommitdiffstats
path: root/src/Dreieck.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Dreieck.java')
-rw-r--r--src/Dreieck.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Dreieck.java b/src/Dreieck.java
new file mode 100644
index 0000000..1d09e17
--- /dev/null
+++ b/src/Dreieck.java
@@ -0,0 +1,79 @@
+import java.util.Scanner;
+
+public class Dreieck
+{
+ public static void main(String[] args)
+ {
+
+ Scanner mys = new Scanner(System.in);
+ int a,b,c;
+ do
+ {
+ System.out.println("Bitte Seitenlaengen eingeben:");
+ a = mys.nextInt();
+ b = mys.nextInt();
+ c = mys.nextInt();
+
+ System.out.println(getType(a, b, c));
+
+ }while(true);
+
+ }
+
+
+
+ public static String getType(int a, int b, int c)
+ {
+ // berechne groesste, mittlere kleinste Seite
+
+ // größte Seite ist größer als die Summe der beiden anderen
+
+ int min, mid, max;
+
+ if(a > b)
+ {
+ mid = a;
+ min = b;
+ }
+ else
+ {
+ mid = b;
+ min = a;
+ }
+
+ if(c > mid)
+ {
+ max = c;
+ }
+ else if(c > min)
+ {
+ max = mid;
+ mid = c;
+ }
+ else
+ {
+ max = mid;
+ mid = min;
+ min = c;
+ }
+
+
+ if(max>min+mid || max==0) // es müsste richtig heißen: || min==0
+ {
+ return "Kein Dreieck";
+ }
+ if(max*max-min*min-mid*mid==0)
+ {
+ return "Rechtwinkliges Dreieck";
+ }
+ if(min == max)
+ {
+ return "Gleichseitiges Dreieck";
+ }
+ else if((max==mid)||(mid==min))
+ {
+ return "Gleichschenkliges Dreieck";
+ }
+ return "Beliebiges Dreieck";
+ }
+}