Calculatives Text

117
/** HiAnanya's project. © Copyright 2012-2013, HiAnanya Limited. All rights reserved. All materials, content and forms contained on this project are the intellectual property of HiAnanya Limited It may not be copied, reproduced, distributed or displayed without HiAnanya Limited's express written permission. */ // enter options to go back to last viewed screen wherever necessary. import java.io.*; class HiAnanyaCalculatives {static InputStreamReader isr = new InputStreamReader (System.in); static BufferedReader br = new BufferedReader (isr); static SkeletonCode obj = new SkeletonCode(); static LoadsOfEffort objOne = new LoadsOfEffort (); public static void main() throws IOException { objOne.loadingScreen(); obj.entranceLogo(); mainMenu(); } private static void clearScreen() //method to clear the screen when called {System.out.println("\f"); } private static void blankSpace() { System.out.println(); } private static void blankSpace(int lines) {for(int i=0; i<=lines; i++) {System.out.println(); } } private static void mainMenu() throws IOException {clearScreen(); int option = 0; boolean validation = false;

Transcript of Calculatives Text

/**HiAnanya's project.© Copyright 2012-2013, HiAnanya Limited.All rights reserved.All materials, content and forms contained on this project are the intellectual property of HiAnanya LimitedIt may not be copied, reproduced, distributed or displayed without HiAnanya Limited's express written permission. */

// enter options to go back to last viewed screen wherever necessary.import java.io.*;class HiAnanyaCalculatives

{static InputStreamReader isr = new InputStreamReader (System.in); static BufferedReader br = new BufferedReader (isr); static SkeletonCode obj = new SkeletonCode(); static LoadsOfEffort objOne = new LoadsOfEffort ();

public static void main() throws IOException { objOne.loadingScreen(); obj.entranceLogo(); mainMenu(); } private static void clearScreen() //method to clear the screen when called {System.out.println("\f"); }

private static void blankSpace() { System.out.println(); }

private static void blankSpace(int lines) {for(int i=0; i<=lines; i++) {System.out.println(); } }

private static void mainMenu() throws IOException {clearScreen(); int option = 0; boolean validation = false;

blankSpace(1); //calling from another method

do {System.out.println("Option 1: Basic arithmatic operations."); System.out.println("Option 2: Secondary arithmatic operations."); System.out.println("Option 3: Operations for two dimensional figures.");//area and perimeters System.out.println("Option 4: Operations for three dimensional figures.");//tsa, csa, volume System.out.println("Option 5: Solution of quadratic eqations"); System.out.println("Option 6: Calculation of Highest Common Factor and Lowest Common Multiple."); System.out.println("Option 7: Varied calculations");//trigonometrical, palindrome, co-prime, armstrong, twin-prime, prime, composite, buzz, fibonacci, reciprocal, //floor and ceil, min and max value, absolute value, rounding, radian from angle, rint, lucky no //random number, exponetial value, degree celcuis to farenheit and pythagorean triplet (another name?) System.out.println("Option 8: Binary of a number"); System.out.println("Option 9: Exit");

blankSpace();

blankSpace(); System.out.println("Enter your choice down there.");

try {option = Integer.parseInt(br.readLine()); validation = true;

} catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. You were requested to entera numeric option between one and seven."); System.out.println("To continue press the 'Enter' button please"); br.readLine(); clearScreen();

} /*if (option > 8 || option == 0) {validation= false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }*/ }while (validation == false);

switch (option) {case 1: optionOne(); break; case 2: optionTwo(); break; case 3: optionThree(); break; case 4: optionFour(); break; case 5: optionFive(); break; case 6: optionSix(); break; case 7: optionSeven(); break; /* case 8: binary(); break;*/

case 9: exits(); break; default: System.out.println("Enter a valid option maybe?"); mainMenu(); break; } }

private static void optionOne() throws IOException {clearScreen(); int option = 0; boolean validation = false; do

{System.out.println("Press 1 for addition"); System.out.println("Press 2 for subtraction"); System.out.println("Press 3 for multiplication"); System.out.println("Press 4 for division"); System.out.println("Press 5 to find the remainder"); System.out.println("Press 6 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); } if(option > 6 || option == 0) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); } } while (validation == false);

switch(option) {case 1: addition(); break; case 2: subtraction(); break; case 3: multiplication(); break; case 4: division(); break; case 5: remain(); break;

case 6: mainMenu(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void addition() throws IOException {boolean validation = false, valid = false; float sum = 0.0f; clearScreen(); int no = 0; do {System.out.println("How many numbers are you planning to add?"); try {no = Integer.parseInt(br.readLine());// how to make it foolproof, where no alphabets are allowed. valid = true; } catch (Exception e) {valid = false; clearScreen(); System.out.println("Error. To continue, please press the 'Enter' button."); br.readLine(); clearScreen(); continue; } } while (valid == false); /* char num = (char) no; if (num != 1 || num != 2 || num != 3 || num != 4 || num != 5 || num != 6 || num != 7 || num != 8 || num != 9 ) { clearScreen(); System.out.println("Error. To continue, please press the 'Enter' button."); br.readLine(); } */

int option = 0; //to return to menu

blankSpace(5); float a[]= new float[no]; for(int i = 0; i < no; i++) { do {System.out.println("Enter the number please."); try {a[i]= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation=false; clearScreen(); System.out.println("Error. To continue, please press the 'Enter' button."); br.readLine(); clearScreen(); }

}while (validation == false); }

for(int j = 0; j < no; j++) {sum= sum+a[j]; } blankSpace(); System.out.println("Calculatives says that the added answer has to be"); System.out.println(sum); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. Press enter to continue"); br.readLine(); clearScreen(); } if (option == 1)

{clearScreen(); mainMenu(); } }

private static void subtraction() throws IOException {boolean validation= false, valid = false; float difference = 0.0f; int no = 0; System.out.println("Please take notice of the fact that Calculatives will subtract the second number from the first."); System.out.println("Also, the subsequent numbers to be subtraced will be subtracted from the previous subtraction answer"); System.out.println("Thank you."); blankSpace(2);

do {System.out.println("How many numbers are you planning to subtract?"); try {no = Integer.parseInt(br.readLine());// how to make it foolproof, where no alphabets are allowed. valid = true; } catch (Exception e) {valid = false; clearScreen(); System.out.println("Error. To continue, please press the 'Enter' button."); br.readLine(); clearScreen(); continue; } } while (valid == false); int option = 0; //to return to menu blankSpace(5); float a[]= new float[no]; blankSpace(); clearScreen();

for(int i = 0; i < a.length; i++) {do {System.out.println("Enter the number down there.");

try {a[i]= Float.parseFloat(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } }while (validation == false); } blankSpace(); for(int j = 1; j < no; j++) { float sum = 0; for (int k = 1; k < no; k++) {sum = sum + a[k]; } difference= a[0]-sum; }

System.out.println("Calculatives says that the subtracted answer has to be"); System.out.println(difference);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); }

if (option == 1) {clearScreen(); mainMenu(); } }

private static void multiplication() throws IOException {boolean validation = false, valid = false; float ans = 1.0f;

int no = 0; do {System.out.println("How many numbers would you want to multiply?"); try {no = Integer.parseInt(br.readLine());// how to make it foolproof, where no alphabets are allowed. valid = true; } catch (Exception e) {valid = false; clearScreen(); System.out.println("Error. To continue, please press the 'Enter' button."); br.readLine(); clearScreen(); continue; } } while (valid == false);

float a[]= new float[no]; int option = 0;

for(int i = 0; i < no; i++) {do {System.out.println("Enter the number"); try {a[i]= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen();

System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } }while(validation==false); }

for(int j=0; j<no; j++) {ans = ans*a[j]; } System.out.println("Calculatives says that the product of the numbers has to be");

System.out.println(ans); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void division() throws IOException {boolean validation= false; float num = 0.0f, den = 0.0f; int option = 0;

{do {System.out.println("Enter the numerator please?");

try {num= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } blankSpace(); System.out.println("Enter the denominator please?"); try {den= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

} while (validation == false); }

System.out.println("Calculatives says that the answer on division has to be"); System.out.println(num/den);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false;

clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void remain() throws IOException {boolean validation= false; float num = 0.0f, den = 0.0f; int option = 0;

do {System.out.println("Enter the numerator please?"); try {num= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the denominator please?"); try {den= Float.parseFloat(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen();

System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

} while (validation == false);

System.out.println("Calculatives says that the remainder valuehas to be"); System.out.println(num%den);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void optionTwo() throws IOException {clearScreen(); int option = 0; boolean validation = false; do {System.out.println("Press 1 for exponential form"); System.out.println("Press 2 for square roots"); System.out.println("Press 3 for natural logarithms");

System.out.println("Press 4 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }

} while (validation == false);

switch(option) {case 1: raisedPowers(); break; case 2: rootsSquare(); break; case 3: naturalLogs(); break; case 4: mainMenu(); break; default: System.out.println("Error. Please enter a valid option?"); break; } }

private static void raisedPowers() throws IOException //raised to a power, square roots {boolean validation = false; double number = 0, power = 0, answer = 0; int option = 0;

do {System.out.println("Enter the number or base.");

try {number = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while (validation == false);

validation= false; do {System.out.println("Enter the power or exponent."); try {power = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while (validation == false);

answer = Math.pow(number,power); System.out.println("Calculatives says that the exponential form has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; }

catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void rootsSquare() throws IOException {boolean validation = false; double number = 0, answer = 0; int option = 0; do {System.out.println("Enter the number that you want to square root"); try {number = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while(validation == false);

answer = Math.sqrt(number); System.out.println("Calculatives says that the square root hasto be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main.");

try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void naturalLogs() throws IOException {boolean validation = false; double number = 0, answer = 0; int option = 0; do {System.out.println("Enter the number whose logarithm you wantto find"); try {number = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while(validation == false);

answer = Math.log(number); System.out.println("Calculatives says that the natural logarithm of " + number + " has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void optionThree() throws IOException {clearScreen(); int option = 0; boolean validation = false; do {System.out.println("Press 1 for calculating perimeters"); System.out.println("Press 2 for calculating areas"); System.out.println("Press 3 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please");

br.readLine(); clearScreen(); } if(option > 3 || option == 0) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); } } while (validation == false);

switch(option) {case 1: perimeterCal(); break; case 2: areaCal(); break; case 3: mainMenu(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void perimeterCal() throws IOException {boolean validation = false; int choice = 0;

blankSpace(); System.out.println("Press 1 to calculate perimeter of a square"); System.out.println("Press 2 to calculate perimeter of a rectangle"); System.out.println("Press 3 to calculate circumference of a circle"); System.out.println("Press 4 to calculate perimeter of a triangle"); System.out.println("Press 5 to calculate perimeter of an equilateral triangle"); System.out.println("Press 6 to calculate perimeter of a rhombus");

System.out.println("Press 7 to calculate perimeter of a trapezium"); System.out.println("Press 8 to calculate perimeter of a parallelogram"); System.out.println("Press 9 to calculate perimeter of a polygon"); System.out.println("Press 10 to go back to the previous screen"); System.out.println();

do {System.out.println("Enter your choice down there."); try {choice = Integer.parseInt(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); } if(choice > 11 || choice == 0) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while (validation == false);

switch(choice) {case 1: squarePeri(); break; case 2: rectanglePeri(); break; case 3: circlePeri(); break; case 4: trianglePeri(); break; case 5: equilateralPeri();

break; case 6: rhombusPeri(); break; case 7: trapeziumPeri(); break; case 8: parallelogramPeri(); break; case 9: polygonPeri(); break; case 10: kitePeri(); break; case 11: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void squarePeri() throws IOException {clearScreen(); boolean validation = false; double side = 0, answer = 0; int option = 0;

System.out.println("Calculation of the perimeter of a square"); blankSpace(2);

do {System.out.println("How much does a side measure?"); try {side=Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(side == 0)

{System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

answer = 4 * side; System.out.println("Calculatives says that the perimeter of the square has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void rectanglePeri() throws IOException {clearScreen(); boolean validation = false; double len = 0, bre = 0; int option = 0;

System.out.println("Calculation of the perimeter of a rectangle"); blankSpace(2);

do {System.out.println("Enter the length of the rectangle please?"); try {len= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(len == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the breadth of the rectangle please?"); try {bre= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

clearScreen(); }

if(bre == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the perimeter of rectangle has to be"); System.out.println(2*(len + bre));

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void circlePeri() throws IOException {clearScreen(); boolean validation = false;

double radii = 0; int option = 0;

System.out.println("Calculation of the circumference of a circle"); blankSpace(2);

do {System.out.println("Enter the value of the radius"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }while (validation == false);

System.out.println("Calculatives says that the circumference of circle has to be"); System.out.println(3.141592653* (2*radii) + " accurately"); System.out.println("and"); System.out.println(3.142 * (2*radii) + " approximately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine());

validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void trianglePeri() throws IOException {clearScreen(); boolean validation = false; double answer = 0; int option = 0; double a[]= new double [3];

System.out.println("Calculation of the perimeter of a triangle"); blankSpace(2);

for (int i = 0; i < a.length; i++) {do {System.out.println("How long is the side of the triangle?"); try {a[i] = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(a[i] == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false); }

answer = a[0] + a[1] + a[2]; System.out.println("Calculatives says that the perimeter of triangle has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void equilateralPeri() throws IOException {clearScreen();

boolean validation = false; int option = 0; double side = 0;

System.out.println("Calculation of the perimeter of an equilateral triangle"); blankSpace(2);

do {System.out.println("How long is the side of the triangle?"); try {side = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false);

System.out.println("Calculatives says that the perimeter of the equilateral triangle has to be"); System.out.println(3 * side);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try

{option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void rhombusPeri() throws IOException {clearScreen(); boolean validation = false; double side = 0, answer = 0; int option = 0;

System.out.println("Calculation of the perimeter of a rhombus"); blankSpace(2); do {System.out.println("How much does a side measure?"); try {side=Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(side == 0)

{System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

answer = 4 * side; System.out.println("Calculatives says that the perimeter of the rhombus has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void trapeziumPeri() throws IOException {clearScreen(); boolean validation = false; double side1 = 0, side2 = 0, side3 = 0, side4 = 0, answer = 0; int option = 0;

System.out.println("Calculation of the perimeter of a trapezium"); blankSpace(2); do {System.out.println("Enter the length of the side please?"); try {side1= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side1 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the side please?"); try {side2= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side2 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the side please??"); try {side3= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side3 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the side please?"); try {side4= Double.parseDouble(br.readLine()); validation= true;

} catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side4 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); } while (validation == false);

answer = side1 + side2 + side3 + side4; System.out.println("Calculatives says that the perimeter of the trapezium has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); }

if (option == 1) {clearScreen(); mainMenu(); } }

private static void parallelogramPeri() throws IOException {clearScreen(); boolean validation = false; double side1 = 0, side2 = 0, side3 = 0, side4 = 0, answer = 0; int option = 0;

System.out.println("Calculation of the perimeter of a parallelogram"); blankSpace(2); do {System.out.println("Enter the length of the first side please?"); try {side1= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side1 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace();

System.out.println("Enter the length of the second side please?"); try {side2= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side2 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the third side please??"); try {side3= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side3 == 0)

{System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the fourth side please?"); try {side4= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side4 == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); } while (validation == false);

answer = side1 + side2 + side3 + side4; System.out.println("Calculatives says that the perimeter of the parallelogram has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void polygonPeri() throws IOException {clearScreen(); boolean validation = false; int option = 0; double side = 0; int number = 0;

System.out.println("Calculation of the perimeter of a polygon"); blankSpace(2);

do {System.out.println("How many sides does the polygon have?"); try {number = Integer.parseInt(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'.");

br.readLine(); clearScreen(); } if(number == 0) {System.out.println("Well, the brains at work say that a zero sided polygon hasn't been created yet. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

System.out.println("What is the length of one side of the " + number + " sided polygon?"); try {side = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the perimeter of the " + number + " sided polygon has to be"); System.out.println(number * side);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void kitePeri() throws IOException {clearScreen(); boolean validation = false; double shorter = 0, longer = 0; int option = 0;

System.out.println("Calculation of the perimeter of a kite"); blankSpace(2);

do {System.out.println("Enter the length of the shorter side please?"); try {shorter= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'.");

br.readLine(); clearScreen(); }

if(shorter == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the length of the longer please?"); try {longer= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(longer == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the perimeter of kite has to be");

System.out.println(2*(shorter + longer));

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void areaCal() throws IOException {boolean validation = false; int choice = 0;

blankSpace(); System.out.println("Press 1 to calculate area of a square"); System.out.println("Press 2 to calculate area of a rectangle"); System.out.println("Press 3 to calculate area of a circle"); System.out.println("Press 4 to calculate area of a triangle"); System.out.println("Press 5 to calculate area of an equilateral triangle"); System.out.println("Press 6 to calculate area of a scalene triangle"); System.out.println("Press 7 to calculate area of a rhombus"); System.out.println("Press 8 to calculate area of a trapezium"); System.out.println("Press 9 to calculate area of a parallelogram");

System.out.println("Press 10 to calculate area of a kite"); System.out.println("Press 11 to go back to the previous screen"); System.out.println();

do {System.out.println("Enter your choice down there."); try {choice = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); } if(choice > 12 || choice == 0) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while (validation == false);

switch(choice) {case 1: squareArea(); break; case 2: rectangleArea(); break; case 3: circleArea(); break; case 4: triangleArea(); break; case 5: equilateralArea(); break; case 6: scaleneArea(); break; case 7: rhombusArea(); break;

case 8: trapeziumArea(); break; case 9: parallelogramArea(); break; case 10: kiteArea(); break; case 11: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void squareArea() throws IOException {clearScreen(); boolean validation = false; double side = 0, answer = 0; int option = 0;

System.out.println("Calculation of the AREA of a square"); blankSpace(2);

do {System.out.println("How much does a side measure?"); try {side=Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(side == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine();

clearScreen(); } } while (validation == false);

answer = Math.pow(side,2); System.out.println("Calculatives says that the area of the square has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void rectangleArea() throws IOException {clearScreen(); boolean validation = false; double len = 0, bre = 0; int option = 0;

System.out.println("Calculation of the AREA of a rectangle"); blankSpace(2);

do {System.out.println("Enter the length of the rectangle please?"); try

{len = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(len == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } blankSpace(); System.out.println("Enter the breadth of the rectangle please?"); try {bre= Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(bre == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue");

br.readLine(); clearScreen(); }

} while (validation == false);

System.out.println("Calculatives says that the area of rectangle has to be"); System.out.println(len*bre);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void circleArea() throws IOException {clearScreen(); boolean validation = false; double radii = 0; int option = 0;

System.out.println("Calculation of the area of a circle"); blankSpace(2);

do {System.out.println("Enter the value of the radius");

try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a radius. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }while (validation == false);

System.out.println("Calculatives says that the area of circle has to be"); System.out.println(3.141592653* Math.pow(radii,2) + " accurately"); System.out.println("and"); System.out.println(3.142 * Math.pow(radii,2) + " approximately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key.");

br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void triangleArea() throws IOException {clearScreen(); boolean validation = false; double answer = 0, base = 0, hei = 0; int option = 0;

System.out.println("Calculation of the AREA of a triangle"); blankSpace(2);

do {System.out.println("What is the length of the base?"); try {base = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(base == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } blankSpace();

System.out.println("Enter the height of the triangle?"); try {hei = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(hei == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

answer = 0.5*base*hei; System.out.println("Calculatives says that the area of triangle has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine();

clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void equilateralArea() throws IOException {clearScreen(); boolean validation = false; int option = 0; double side = 0;

System.out.println("Calculation of the area of an equilateral triangle"); blankSpace(2);

do {System.out.println("How long is the side of the triangle?"); try {side = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(side == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false);

System.out.println("Calculatives says that the area of the equilateral triangle has to be"); System.out.println((Math.sqrt(3)*Math.pow(side,2))/4 + " accurately"); System.out.println("and"); System.out.println((1.723*Math.pow(side,2))/4 + " approximately");

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void scaleneArea() throws IOException {clearScreen(); boolean validation = false; double answer = 0, s = 0; int option = 0; double a[]= new double [3];

System.out.println("Calculation of the area of a scalene triangle"); blankSpace(2);

for (int i = 0; i < a.length; i++) {do {System.out.println("How long is the side of the triangle?"); try {a[i] = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } if(a[i] == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false); }

s = (a[0] + a[1] + a[2])/2; answer = Math.sqrt(s*(s-a[0])*(s-a[1])*(s-a[2])); System.out.println("Calculatives says that the area of the scalene triangle has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; }

catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void rhombusArea() throws IOException {clearScreen();

int option = 0;

boolean validation = false; do {System.out.println("Press 1 to calculate area of rhombus whenyou know the base and the height."); System.out.println("Press 2 to calculate area of rhombus when you know the measures of diagonals."); System.out.println("Press 3 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }

if(option > 3 || option == 0) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); } } while (validation == false);

switch(option) {case 1: rhombusAreaBH(); break; case 2: rhombusAreaDiag(); break; case 3: areaCal(); break; default: System.out.println("Error. Please enter a valid option?"); }

}

private static void rhombusAreaBH() throws IOException {clearScreen(); boolean validation = false; double answer = 0, base = 0, hei = 0; int option = 0;

System.out.println("Calculation of the area of a rhombus when base and height are known"); blankSpace(2);

do {System.out.println("What is the length of the base?"); try {base = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen();

System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(base == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } blankSpace(); System.out.println("What is the height or perpendicular distance?"); try {hei = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(hei == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a perpendicular distance. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

answer = base * hei;

System.out.println("Calculatives says that the area of the rhombus has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void rhombusAreaDiag() throws IOException {clearScreen(); boolean validation = false; double answer = 0; int option = 0; double a[]= new double [2];

System.out.println("Calculation of the area of a rhombus when length of diagonals are known"); blankSpace(2);

for (int i = 0; i < a.length; i++) {do {System.out.println("What is the length of the diagonal?"); try {a[i] = Double.parseDouble(br.readLine());

validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } if(a[i] == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a rhombus. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false); }

answer = (a[0]*a[1])/2; System.out.println("Calculatives says that the area of the rhombus has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); }

if (option == 1) {clearScreen(); mainMenu(); }

}

private static void trapeziumArea() throws IOException {clearScreen(); boolean validation = false; double hei = 0; int option = 0; double a[]= new double [2];

System.out.println("Calculation of the AREA of a trapezium"); blankSpace(2);

for (int i = 0; i < a.length; i++) {do {System.out.println("What is the length of the side?"); try {a[i] = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(a[i] == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } blankSpace();

System.out.println("Enter the height of the rectangle please?"); try {hei = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(hei == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false);

System.out.println("Calculatives says that the area of trapezium has to be"); System.out.println(0.5*(a[0]+a[1])*hei);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key.");

br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

}

private static void parallelogramArea() throws IOException

{clearScreen(); boolean validation = false; double answer = 0, base = 0, hei = 0; int option = 0;

System.out.println("Calculation of the area of a parallelogram"); blankSpace(2);

do {System.out.println("What is the length of the base?"); try {base = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(base == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2);

System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } blankSpace(); System.out.println("What is the height or perpendicular distance?"); try {hei = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(hei == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a perpendicular distance. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

answer = base * hei; System.out.println("Calculatives says that the area of the parallelogram has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; }

catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void kiteArea() throws IOException {clearScreen(); boolean validation = false; double answer = 0; int option = 0; double a[]= new double [2];

System.out.println("Calculation of the area of a kite"); blankSpace(2);

for (int i = 0; i < a.length; i++) {do {System.out.println("What is the length of the diagonal?"); try {a[i] = Double.parseDouble(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } if(a[i] == 0)

{System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a kite. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

} while (validation == false); }

answer = (a[0]*a[1])/2; System.out.println("Calculatives says that the area of the kite has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void optionFour() throws IOException {clearScreen(); int option = 0; boolean validation = false;

do {System.out.println("Press 1 to calculate volume"); System.out.println("Press 2 to calculate curved surface areas"); System.out.println("Press 3 to calculate total surface areas"); System.out.println("Press 4 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); } /*if(option > 4 || option == 0) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }*/ } while (validation == false);

switch(option) {case 1: volCal(); break; case 2: csaCal(); break; case 3: tsaCal(); break; case 4: mainMenu(); break;

default: System.out.println("Error. Please enter a valid option?"); } }

private static void volCal() throws IOException {clearScreen(); boolean validation = false; int choice = 0;

blankSpace(); System.out.println("Press 1 to calculate volume of a cube"); System.out.println("Press 2 to calculate volume of a cuboid"); System.out.println("Press 3 to calculate volume of a sphere"); System.out.println("Press 4 to calculate volume of a hemisphere"); System.out.println("Press 5 to calculate volume of a cone"); System.out.println("Press 6 to calculate volume of a cylinder"); System.out.println("Press 7 to go back to the previous screen"); System.out.println();

do {System.out.println("Enter your choice down there."); try {choice = Integer.parseInt(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); } if(choice > 7 || choice == 0) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); clearScreen();

} } while (validation == false);

switch(choice) {case 1: cubeVol(); break; case 2: cuboidVol(); break; case 3: sphereVol(); break; case 4: hemisVol(); break; case 5: coneVol(); break; case 6: cylVol(); break; case 7: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void cubeVol() throws IOException {clearScreen(); boolean validation = false; double side = 0, answer = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a cube"); blankSpace(2);

do {System.out.println("How much does a side measure?"); try {side = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'.");

br.readLine();

if(side == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }

} while (validation == false);

answer = Math.pow(side,3); System.out.println("Calculatives says that the volume of the cube has to be"); System.out.println(answer);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void cuboidVol() throws IOException {clearScreen();

boolean validation = false; double l = 0, b = 0, h = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a cuboid"); blankSpace(2);

do {System.out.println("Enter the length of the cuboid please?"); try {l = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(l == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the breadth of the cuboid please?"); try {b = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen();

System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(b == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cuboid please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the volume of the cuboid has to be"); System.out.println(l * b * h);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void sphereVol() throws IOException {clearScreen(); boolean validation = false; double radii = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a sphere"); blankSpace(2);

do {System.out.println("How much does the radius measure?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false;

clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a radius. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the volume of the sphere has to be"); System.out.println((4*3.142*Math.pow(radii,3))/3 + " approximately"); System.out.println((4*3.141592653*Math.pow(radii,3))/3 + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void hemisVol() throws IOException {clearScreen(); boolean validation = false; double radii = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a hemisphere"); blankSpace(2);

do {System.out.println("How much does the radius measure?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a radius. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the volume of the hemisphere has to be"); System.out.println((2*3.142*Math.pow(radii,3))/3 + " approximately"); System.out.println((2*3.141592653*Math.pow(radii,3))/3 + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void coneVol() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a cone"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cone please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen();

}

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cone please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the volume of the cone has to be"); System.out.println((1/3)*3.142*Math.pow(radii,2)*h + " approximately");

System.out.println((1/3)*3.141592653*Math.pow(radii,2)*h + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void cylVol() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0; int option = 0;

System.out.println("Calculation of the VOLUME of a cylinder"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cylinder please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen();

System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cylinder please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the volume of the cylinder has to be"); System.out.println(3.142*Math.pow(radii,2)*h + " approximately"); System.out.println(3.141592653*Math.pow(radii,2)*h + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void csaCal() throws IOException {clearScreen(); boolean validation = false; int choice = 0;

blankSpace(); System.out.println("Press 1 to calculate curved surface area of a cube"); System.out.println("Press 2 to calculate curved surface area of a cuboid"); System.out.println("Press 3 to calculate curved surface area of a sphere"); System.out.println("Press 4 to calculate curved surface area of a hemisphere");

System.out.println("Press 5 to calculate curved surface area of a cone"); System.out.println("Press 6 to calculate curved surface area of a cylinder"); System.out.println("Press 7 to go back to the previous screen"); System.out.println();

do {System.out.println("Enter your choice down there."); try {choice = Integer.parseInt(br.readLine()); validation= true; } catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); } if(choice > 7 || choice == 0) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); clearScreen(); } } while (validation == false);

switch(choice) {case 1: cubeCSA(); break; case 2: cuboidCSA(); break; case 3: sphereCSA(); break; case 4: hemisCSA(); break; case 5: coneCSA(); break; case 6: cylCSA();

break; case 7: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void cubeCSA() throws IOException {clearScreen(); boolean validation = false; double side = 0; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a cube"); blankSpace(2);

do {System.out.println("How much does a side measure?"); try {side = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

if(side == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }

} while (validation == false);

System.out.println("Calculatives says that the curved surface area of the cube has to be"); System.out.println(4*side*side);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void cuboidCSA() throws IOException {clearScreen(); boolean validation = false; double l = 0, b = 0, h = 0; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a cuboid"); blankSpace(2);

do {System.out.println("Enter the length of the cuboid please?"); try {l = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e)

{validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(l == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the breadth of the cuboid please?"); try {b = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(b == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cuboid please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the curved surface area of the cuboid has to be"); System.out.println(4*((l*b) + (l*h)));

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen();

System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void sphereCSA() throws IOException {clearScreen(); boolean validation = false; double radius = 0; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a sphere"); blankSpace(2);

do {System.out.println("How much does the radius measure?"); try {radius = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

if(radius == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

}

} while (validation == false);

System.out.println("Calculatives says that the curved surface area of the sphere has to be"); System.out.println((4*3.142*Math.pow(radius,2)) + " approximately"); System.out.println((4*3.141592653*Math.pow(radius,2)) + " accurately");

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void hemisCSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a hemisphere"); blankSpace(2);

do

{System.out.println("How much does the radius measure?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a radius. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the curved surface area of the hemisphere has to be"); System.out.println((2*3.142*Math.pow(radii,2)) + " approximately"); System.out.println((2*3.141592653*Math.pow(radii,2)) + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine();

clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void coneCSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0, l = 0 ; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a cone"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cone please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cone please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

l = Math.sqrt((h*h) + (radii*radii)); System.out.println("Calculatives says that the curved surface area of the cone has to be"); System.out.println(3.142*radii*l + " approximately"); System.out.println(3.141592653*radii*l + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen();

System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void cylCSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0; int option = 0;

System.out.println("Calculation of the CURVED SURFACE AREA of a cylinder"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cylinder please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2);

System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cylinder please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the curved surface area of the cylinder has to be"); System.out.println(2*3.142*radii*h + " approximately"); System.out.println(2*3.141592653*radii*h + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; }

catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void tsaCal() throws IOException {clearScreen(); boolean validation = false; int choice = 0;

blankSpace(); System.out.println("Press 1 to calculate total surface area ofa cube"); System.out.println("Press 2 to calculate total surface area ofa cuboid"); System.out.println("Press 3 to calculate total surface area ofa sphere"); System.out.println("Press 4 to calculate total surface area ofa hemisphere"); System.out.println("Press 5 to calculate total surface area ofa cone"); System.out.println("Press 6 to calculate total surface area ofa cylinder"); System.out.println("Press 7 to go back to the previous screen"); System.out.println();

do {System.out.println("Enter your choice down there."); try {choice = Integer.parseInt(br.readLine()); validation= true; }

catch(Exception e) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); } if(choice > 7 || choice == 0) {validation= false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'"); br.readLine(); clearScreen(); } } while (validation == false);

switch(choice) {case 1: cubeTSA(); break; case 2: cuboidTSA(); break; case 3: sphereTSA(); break; case 4: hemisTSA(); break; case 5: coneTSA(); break; case 6: cylTSA(); break; case 7: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static void cubeTSA() throws IOException {clearScreen(); boolean validation = false; double side = 0; int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of acube"); blankSpace(2);

do {System.out.println("How much does a side measure?"); try {side = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

if(side == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }

} while (validation == false);

System.out.println("Calculatives says that the total surface area of the cube has to be"); System.out.println(6*side*side);

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false;

clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void cuboidTSA() throws IOException {clearScreen(); boolean validation = false; double l = 0, b = 0, h = 0; int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of acuboid"); blankSpace(2);

do {System.out.println("Enter the length of the cuboid please?"); try {l = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(l == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue");

br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the breadth of the cuboid please?"); try {b = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(b == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cuboid please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the total surface area of the cuboid has to be"); System.out.println(2*((l*b) + (b*h) + (l*h)));

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void sphereTSA() throws IOException {clearScreen(); boolean validation = false; double radius = 0;

int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of asphere"); blankSpace(2);

do {System.out.println("How much does the radius measure?"); try {radius = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

if(radius == 0) {System.out.println("Well, the brains at work say thatzero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } }

} while (validation == false);

System.out.println("Calculatives says that the total surface area of the sphere has to be"); System.out.println((4*3.142*Math.pow(radius,2)) + " approximately"); System.out.println((4*3.141592653*Math.pow(radius,2)) + " accurately");

blankSpace(3);

System.out.println("Press 1 to go back to main."); try

{option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void hemisTSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0; int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of ahemisphere"); blankSpace(2);

do {System.out.println("How much does the radius measure?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

if(radii == 0)

{System.out.println("Well, the brains at work say that zero cannot be a possible measure for a radius. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the total surface area of the hemisphere has to be"); System.out.println((2*3.142*Math.pow(radii,2)) + " approximately"); System.out.println((2*3.141592653*Math.pow(radii,2)) + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void coneTSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0, l = 0 ; int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of acone"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cone please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cone please?"); try {h = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine();

clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

l = Math.sqrt((h*h) + (radii*radii)); System.out.println("Calculatives says that the total surface area of the cone has to be"); System.out.println((3.142*radii*l) + (3.142*radii*radii) + " approximately"); System.out.println((3.141592653*radii*l) + (3.141592653*radii*radii) + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void cylTSA() throws IOException {clearScreen(); boolean validation = false; double radii = 0, h = 0; int option = 0;

System.out.println("Calculation of the TOTAL SURFACE AREA of acylinder"); blankSpace(2);

do {System.out.println("Enter the radius of the base of the cylinder please?"); try {radii = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(radii == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); }

blankSpace(); System.out.println("Enter the height of the cylinder please?"); try {h = Double.parseDouble(br.readLine()); validation = true; }

catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(h == 0) {System.out.println("Well, the brains at work say that zero cannot be a possible measure for a side. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); } } while (validation == false);

System.out.println("Calculatives says that the curved surface area of the cylinder has to be"); System.out.println((2*3.142*radii*h) + (2*3.142*radii*radii) +" approximately"); System.out.println((2*3.141592653*radii*h) + (2*3.141592653*radii*radii) + " accurately"); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen();

mainMenu(); }

}

private static void optionFive() throws IOException {clearScreen(); int option = 0; boolean validation = false; double a = 0, b = 0, c = 0, d = 0, r1 = 0, r2 = 0;

System.out.println("A quadratic equation has two roots, and isin the form of ax^2 + bx + c = 0, where a, b and c are constants and ais not equal to zero"); blankSpace(); do {System.out.println("Enter the value of a"); try {a = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

if(a == 0) {System.out.println("Well, the brains at work say that thevalue of 'a' has to be non zero. "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen(); optionFive(); }

} while (validation == false);

do {blankSpace(); System.out.println("Enter the value of b"); try {b = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); } } while (validation == false);

do {blankSpace(); System.out.println("Enter the value of c"); try {c = Double.parseDouble(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); clearScreen(); }

} while (validation == false);

/* if (a == 0) {System.out.println("Well, the brains at work say that the value of 'a' has to be anything but zero "); System.out.println("Think about it."); blankSpace(2); System.out.println("Press enter to continue"); br.readLine(); clearScreen();

optionFive(); } */ if (a != 0 ) {d = b*b - (4*a*c);

if( d > 0) {r1 = ( -b + Math.sqrt(d) )/2*a; r2 = ( -b - Math.sqrt(d) )/2*a; System.out.println("The roots will be real and unequal"); blankSpace(); System.out.println("The roots are :"); System.out.println(r1 + r2); blankSpace(); }

else if (d < 0) {System.out.println("The roots are imaginary and hence cannot be found"); }

else if (d == 0) {r1 = (-b)/2*a; r2 = r1; System.out.println("The roots will be real and equal"); blankSpace(); System.out.println("The roots are :"); System.out.println(r1 + r2); blankSpace(); }

}

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e)

{validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); }

}

private static void optionSix() throws IOException {clearScreen(); int option = 0; boolean validation = false; do {System.out.println("Press 1 to calculate the Highest Common Factors"); System.out.println("Press 2 to calculate the Lowest CommonMultiples"); System.out.println("Press 3 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }

} while (validation == false);

switch(option) {case 1: HCF(); break; case 2: LCM(); break; case 3: mainMenu(); break; default: System.out.println("Error. Please enter a valid option?"); break; } }

private static void HCF() throws IOException // only with whole number {clearScreen(); boolean validation = false; int a = 0, b = 0; int option = 0;

System.out.println("Calculation of the HIGHEST COMMON FACTOR."); blankSpace(2);

do {System.out.println("Enter the first number please"); try {a = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

blankSpace(); System.out.println("Enter the second number please"); try {b = Integer.parseInt(br.readLine()); validation = true;

} catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

} while (validation == false);

int t = 0, p = 0, r = 0, hcf = 0, lcm = 0;

if (a < b) {t = a; a = b; b = t; //swapping } p = a*b; r = a%b; while (r != 0) { a = b; b = r; r = a%b; }

hcf = b; lcm = p/hcf;

System.out.println("Calculatives says that highest common factor of " + a + " and " + b + " is"); System.out.println(hcf); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen();

System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void LCM() throws IOException {clearScreen(); boolean validation = false; int a = 0, b = 0; int option = 0;

System.out.println("Calculation of the LOWEST COMMON MULTIPLE."); blankSpace(2);

do {System.out.println("Enter the first number please"); try {a = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

blankSpace(); System.out.println("Enter the second number please"); try {b = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false;

clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

} while (validation == false);

int t = 0, p = 0, r = 0, hcf = 0, lcm = 0;

if (a < b) {t = a; a = b; b = t; //swapping } p = a*b; r = a%b; while (r != 0) { a = b; b = r; r = a%b; }

hcf = b; lcm = p/hcf;

System.out.println("Calculatives says that lowest common multiple of " + a + " and " + b + " is"); System.out.println(lcm); blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen();

} if (option == 1) {clearScreen(); mainMenu(); } }

private static void optionSeven() throws IOException {clearScreen(); int option = 0; boolean validation = false; do {System.out.println("Press 1 to calculate trigonometrical values"); System.out.println("Press 2 to calculate radians"); System.out.println("Press 3 to check whether a number is palindrome"); System.out.println("Press 4 to check whether numbers are co-prime"); System.out.println("Press 5 to check whether a number is armstrong"); System.out.println("Press 6 to check whether numbers are twin prime"); System.out.println("Press 7 to check whether a number is prime"); System.out.println("Press 8 to check whether a number is composite"); System.out.println("Press 9 to check whether a number is buzz"); System.out.println("Press 10 to check whether a number is fibonacci"); System.out.println("Press 11 to find reciprocal"); System.out.println("Press 12 to find the floor and ceilingvalues"); System.out.println("Press 13 to find minimum and maximum values"); System.out.println("Press 14 to check whether a number is palindrome"); System.out.println("Press 15 to find absolute value of a number"); System.out.println("Press 16 to round a number"); System.out.println("Press 17 to check whether a number is a lucky number");

System.out.println("Press 18 to generate a random number"); System.out.println("Press 19 for temperature conversions"); System.out.println("Press 20 to find a pythagorean triplet"); System.out.println("Press 21 for rint"); System.out.println("Press 23 to assort numbers"); System.out.println("Press 24 to go back to the previous screen."); blankSpace(); System.out.println("Enter your choice down there."); try {option = Integer.parseInt(br.readLine()); clearScreen(); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue press the 'Enter' button please"); br.readLine(); clearScreen(); }

} while (validation == false);

switch(option) {case 1: trigonometrically(); break; case 2: rectanglePeri(); break; case 3: circlePeri(); break; case 4: trianglePeri(); break; case 5: equilateralPeri(); break; case 6: rhombusPeri(); break; case 7: trapeziumPeri(); break;

case 8: parallelogramPeri(); break; case 9: polygonPeri(); break; case 10: kitePeri(); break; case 11: optionThree(); break; case 12: rectanglePeri(); break; case 13: circlePeri(); break; case 14: trianglePeri(); break; case 15: equilateralPeri(); break; case 16: rhombusPeri(); break; case 17: luckyNumero(); break; case 18: parallelogramPeri(); break; case 19: polygonPeri(); break; case 20: kitePeri(); break; case 21: kitePeri(); break; case 22: optionThree(); break; default: System.out.println("Error. Please enter a valid option?"); } }

private static int sumDigits (int a) {int s = 0, d = 0; while (a > 0) {d = a % 10; s = s + d; a = a/10; } return s;

}

private static void luckyNumero() throws IOException {clearScreen(); boolean validation = false; int a = 0, b = 0; int option = 0;

System.out.println("Validification of lucky numbers"); blankSpace(2);

do {System.out.println("Enter the number please"); try {a = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

} while (validation == false);

int sum = 0; while (a >= 10) { sum = sumDigits(a); a = sum; }

if (sum == 1 || a == 1) {System.out.println(a + " is a Lucky number"); }

else {System.out.println(a + " is a not a Lucky number"); }

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

private static void trigonometrically() throws IOException {clearScreen(); boolean validation = false; int a = 0, b = 0; int option = 0;

System.out.println("Validification of lucky numbers"); blankSpace(2);

do {System.out.println("Enter the number please"); try {a = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Awh snap! You must've pressed the wrong button. To retry, press 'Enter'."); br.readLine(); }

} while (validation == false);

int sum = 0; while (a >= 10) { sum = sumDigits(a); a = sum; }

if (sum == 1 || a == 1) {System.out.println(a + " is a Lucky number"); }

else {System.out.println(a + " is a not a Lucky number"); }

blankSpace(3);

System.out.println("Press 1 to go back to main."); try {option = Integer.parseInt(br.readLine()); validation = true; } catch(Exception e) {validation = false; clearScreen(); System.out.println("Error. To continue please press the 'Enter' key."); br.readLine(); clearScreen(); } if (option == 1) {clearScreen(); mainMenu(); } }

public static void exits() throws IOException { int option = 0;

System.out.println("\f"); System.out.println("Thank you for visiting and using Calculatives."); System.out.println();

System.out.println("Press 'Enter' to exit OR"); System.out.println("Press 1 to go back to main."); option = Integer.parseInt(br.readLine()); if (option == 1) {System.out.println("\f"); mainMenu(); } br.readLine(); System.exit(0);

}

}