Basic.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Basic class to perform basic functions for our Graphing Calculator
  3. * (+, -, *, /)
  4. * Lauren Green
  5. * 10/19/18
  6. */
  7. public class Basic
  8. {
  9. double input1 = 0;
  10. double input2 = 0;
  11. String operation = "";
  12. double answer;
  13. public void Basic()
  14. {
  15. Console.println("Basic Calculator Options"
  16. + "\n1: Addition"
  17. + "\n2: Subtraction"
  18. + "\n3: Multiplication"
  19. + "\n4: Division"
  20. + "\n5: Cancel - returns to Main Menu");
  21. }
  22. //addition method
  23. public double getSum(double x, double y) {
  24. answer = x + y;
  25. return answer;
  26. }
  27. //subtraction method
  28. public double getDiff(double x, double y) {
  29. answer = x - y;
  30. return answer;
  31. }
  32. //multiplication method
  33. public double getProduct(double x, double y) {
  34. answer = x * y;
  35. return answer;
  36. }
  37. //division method
  38. public double getQuotient(double x, double y) {
  39. answer = x / y;
  40. return answer;
  41. }
  42. }