CoreFeatures.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Write a description of class CoreFeatures here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class CoreFeatures extends MainApplication {
  8. // instance variables - replace the example below with your own
  9. private double x;
  10. private double addedNumbers;
  11. //addition
  12. private double subtractedNumbers;
  13. //subtraction
  14. private double multipliedNumbers;
  15. //multiplication
  16. private double dividedNumbers;
  17. //divide
  18. private double squaredNumber;
  19. //square
  20. private double squareRoot;
  21. //square root
  22. private boolean calcRunning;
  23. //calculator status
  24. private double invertedNumber;
  25. //changing the sign of a number
  26. /**
  27. * Constructor for objects of class CoreFeatures
  28. */
  29. public CoreFeatures(){
  30. // initialise instance variables
  31. x = 0;
  32. }
  33. public double addNumbers(double adding1, double adding2){
  34. addedNumbers = adding1 + adding2;
  35. return addedNumbers;}
  36. public double subtractNumbers(double subtracting1, double subtracting2){
  37. subtractedNumbers = subtracting1 - subtracting2;
  38. return subtractedNumbers;}
  39. public double multiplyNumbers(double multiplying1, double multiplying2){
  40. multipliedNumbers = multiplying1 * multiplying2;
  41. return multipliedNumbers;}
  42. public double divideNumbers(double dividing1, double dividing2){
  43. if (dividing2 == 0){
  44. System.out.println("**ERROR** CANNOT DIVIDE BY ZERO.");} else {
  45. dividedNumbers = dividing1 / dividing2;
  46. return dividedNumbers;}
  47. /*double userCorrectedInput = Console.getDoubleInput("**Err** CANNOT DIVIDE BY ZERO. Please clear the calculator.");
  48. return userCorrectedInput;*/
  49. /*dividedNumbers = dividing1 / dividing2;
  50. return dividedNumbers;*/
  51. return dividedNumbers;}
  52. public double squareNumber(double squaring){
  53. squaredNumber = squaring * squaring;
  54. return squaredNumber;}
  55. public double squareRoot(double squareRooting){
  56. squareRoot = squareRoot(squareRooting);
  57. return squareRoot;}
  58. public double invertSign(double inverting){
  59. invertedNumber = inverting * -1;
  60. return invertedNumber;
  61. }
  62. public boolean calcRunning(){
  63. calcRunning = false;
  64. return calcRunning;
  65. }
  66. }