Noah Vogt 4 лет назад
Родитель
Сommit
2971bbc3da

+ 24 - 3
inputOutputFlanagan/bigIntegerFakultaet.java

@@ -14,11 +14,18 @@ public class bigIntegerFakultaet {
         // get factorial input
         try {
             factorial = Db.readInt("factorial = ");
+            System.out.println("factorial input = " + factorial);
         } catch (NumberFormatException e) {
             Db.show("Error: no valid integer input provided");
             System.exit(1);
         }
 
+        // print dashes
+        for (int i = 0; i < 80; i++) {
+            System.out.format("-");
+        }
+        System.out.println();
+
         //  validate that: factorial >= 0
         if (factorial < 0) {
             Db.show("Error: input cannot be negative");
@@ -26,7 +33,13 @@ public class bigIntegerFakultaet {
         }
 
         // print top table row
-        System.out.format("n \tn!\n\n");
+        System.out.format("n \tn!\n");
+
+        // print dashes
+        for (int i = 0; i < 80; i++) {
+            System.out.format("-");
+        }
+        System.out.println();
 
         // special case: 0! = 1
         if (factorial == 0) {
@@ -37,11 +50,19 @@ public class bigIntegerFakultaet {
         // use big integer
         BigInteger bigFactorial = BigInteger.valueOf(factorial);
 
-        for (BigInteger n = BigInteger.valueOf(1); n.compareTo(bigFactorial) <= 0; n = n.add(BigInteger.ONE))
-        {
+        for (BigInteger n = BigInteger.valueOf(1); n.compareTo(bigFactorial) <= 0; n = n.add(BigInteger.ONE)) {
             res = n.multiply(resn); // current result
             resn = res; // new overall result
             System.out.format("%d \t%d (%d-digit)\n", n, res, res.toString().length());
         }
+
+        // print dashes
+        for (int i = 0; i < 80; i++) {
+            System.out.format("-");
+        }
+        System.out.println();
+
+        System.out.println("Successfully executed the task ...");
+        System.exit(0);
     }
 }

+ 17 - 0
inputOutputFlanagan/bigIntegerPotenzen.java

@@ -14,6 +14,7 @@ public class bigIntegerPotenzen {
         // get base input
         try {
             base = Db.readInt("base = ");
+            System.out.println("base input = " + base);
         } catch (NumberFormatException e) {
             Db.show("Error: no valid integer input provided");
             System.exit(1);
@@ -22,11 +23,18 @@ public class bigIntegerPotenzen {
         // get exponent input
         try {
             exponent = Db.readInt("exponent = ");
+            System.out.println("exponent input = " + exponent);
         } catch (NumberFormatException e) {
             Db.show("Error: no valid integer input provided");
             System.exit(1);
         }
 
+        // print dashes
+        for (int i = 0; i < 80; i++) {
+            System.out.format("-");
+        }
+        System.out.println();
+
         //  validate that: exponent, base >= 0
         if (base < 0) {
             Db.show("Error: 'base' cannot be negative");
@@ -45,5 +53,14 @@ public class bigIntegerPotenzen {
 
             System.out.format("n = %d \t %d^%d \t %d (%d-digit)\n", n, base, n, res, res.toString().length());
         }
+        
+        // print dashes
+        for (int i = 0; i < 80; i++) {
+            System.out.format("-");
+        }
+        System.out.println();
+
+        System.out.println("Successfully executed the task ...");
+        System.exit(0);
     }
 }