RealAdvanced.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Method for the RealAdvanced class
  3. *
  4. * @Michelle DiMarino
  5. * @10.21.18
  6. */
  7. import java.util.*;
  8. public class RealAdvanced
  9. {
  10. public void realAdvanced()
  11. {
  12. Console.println("Please Select one of the following Calculations: " +"\n"+
  13. "1: x^2" + "\n"+
  14. "2: x^y" + "\n"+
  15. "3: 1/x" + "\n"+
  16. "4: Switch Sign of x" + "\n"+
  17. "5: Absolute Value of x" + "\n"+
  18. "6: Square Root of x" + "\n"+
  19. "7: Factorial x!"+"\n"+
  20. "8: Return to Main Menu");
  21. }
  22. // method to find x^2
  23. public double squared(double x){
  24. return Math.pow(x,2);
  25. }
  26. // method to find x^y
  27. public double exponent(double x, double y){
  28. return Math.pow(x,y);
  29. }
  30. // method to find the inverse of x
  31. public double inverse(double x){
  32. return 1/x;
  33. }
  34. // method to switch sign of x
  35. public double opposite(double x){
  36. double opposite1 = -1 * x;
  37. return opposite1;
  38. }
  39. public double absoluteValue(double x){
  40. return Math.abs(x);
  41. }
  42. public double sqrt(double x){
  43. return Math.sqrt(x);
  44. }
  45. public double factorial(double x){
  46. double answer = 1;
  47. for (double i = x; i >0; i--){
  48. answer = answer * i;
  49. }
  50. return answer;
  51. }
  52. }