diff --git a/src/com/concordia/soen6441/incarnation1/CheersMath_I1.java b/src/com/concordia/soen6441/incarnation1/CheersMath_I1.java index 9f8d5c8..f4b8d92 100644 --- a/src/com/concordia/soen6441/incarnation1/CheersMath_I1.java +++ b/src/com/concordia/soen6441/incarnation1/CheersMath_I1.java @@ -61,7 +61,7 @@ protected double getCos(double x) { } i++; } while (i <= CheersConfig_I1.COS_ITERATIONS); - return round(sum); + return sum; } // 4(1 - 1/3 + 1/5 - 1/7 + ...) diff --git a/src/com/concordia/soen6441/incarnation2/CheersMath_I2.java b/src/com/concordia/soen6441/incarnation2/CheersMath_I2.java index 14aaa4b..1af56da 100644 --- a/src/com/concordia/soen6441/incarnation2/CheersMath_I2.java +++ b/src/com/concordia/soen6441/incarnation2/CheersMath_I2.java @@ -33,7 +33,7 @@ protected double convertDegreeToRadian(double deg) { protected double roundIntermediate(double nb) { double prec = Math.pow(10, precision); nb *= prec; - nb = Math.round(nb); + nb = (int) Math.round(nb); nb /= prec; return nb; } @@ -41,9 +41,9 @@ protected double roundIntermediate(double nb) { // Precision of Output value is rounded up to number of decimal places selected by user protected double roundOutput(double nb){ - double prec = Math.pow(10, precisionOutput); + int prec = 10^precisionOutput; nb *= prec; - nb = Math.round(nb); + nb = (int) nb; nb /= prec; return nb; } @@ -51,13 +51,13 @@ protected double roundOutput(double nb){ // To get cosine value using built-in method protected double getCos(double x) { double sum = Math.cos(x); - return roundIntermediate(sum); + return sum; } //To get Pi value using java library protected double getPi() { double piValue = Math.PI; - return roundIntermediate(4 * piValue); + return piValue; } // http://mathcentral.uregina.ca/QQ/database/QQ.09.00/roble1.html diff --git a/src/com/concordia/soen6441/incarnation2/CheersXML_I2.java b/src/com/concordia/soen6441/incarnation2/CheersXML_I2.java new file mode 100644 index 0000000..4d524f7 --- /dev/null +++ b/src/com/concordia/soen6441/incarnation2/CheersXML_I2.java @@ -0,0 +1,39 @@ +package com.concordia.soen6441.incarnation2; + +public class CheersXML_I2 { + + public static boolean generateXML(double radius, int precision, int precisionOutput, String output){ + boolean x = false; + try{ + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println(" "); + System.out.println(" "); + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println(""); + System.out.println("]>"); + System.out.println(""); + System.out.println("\t"); + System.out.println("\t\t"+radius+""); + System.out.println("\t\t"+precision+""); + System.out.println("\t\t"+precisionOutput+""); + System.out.println("\t"); + System.out.println("\t"); + System.out.println("\t\t"+output+""); + System.out.println("\t"); + System.out.println(""); + x = true; + } + catch(Exception e){ + System.out.println("XML cannot be generated. Please try again..!"); + } + return x; + } +} diff --git a/src/com/concordia/soen6441/ui/CheersUi_I1.java b/src/com/concordia/soen6441/ui/CheersUi_I1.java index c1bfd8f..ae5ef66 100644 --- a/src/com/concordia/soen6441/ui/CheersUi_I1.java +++ b/src/com/concordia/soen6441/ui/CheersUi_I1.java @@ -47,7 +47,6 @@ public static void main(String args[]) throws CheersException_I1 { CheersMath_I1 cheersMath = new CheersMath_I1(radius, precision, precisionOutput); System.out.println("The two coasters need to be moved " + cheersMath.getLength() + " inch far from each other"); - case CheersConfig_I1.OPERATION_EXIT: System.out.println("Program Cheers Ended!"); System.exit(0); @@ -63,5 +62,5 @@ public static void main(String args[]) throws CheersException_I1 { System.out.println("Program ended"); } } - + } diff --git a/src/com/concordia/soen6441/ui/CheersUi_I2.java b/src/com/concordia/soen6441/ui/CheersUi_I2.java index d42dde7..6e8f215 100644 --- a/src/com/concordia/soen6441/ui/CheersUi_I2.java +++ b/src/com/concordia/soen6441/ui/CheersUi_I2.java @@ -50,8 +50,11 @@ public static void main(String args[]) throws CheersException_I2 { CheersMath_I2 cheersMath = new CheersMath_I2(radius, precision, precisionOutput); DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); df.setMaximumFractionDigits(340); + boolean res = CheersXML_I2.generateXML(radius,precision,precisionOutput,df.format(cheersMath.getLength())); + if(res){ System.out.println("The two coasters need to be moved " + df.format(cheersMath.getLength()) + " inch far from each other"); + } case CheersConfig_I2.OPERATION_EXIT: System.out.println("Program Cheers Ended!");