Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. // APCS1 Lab Test 2
  2. //
  3. // Prog11.java
  4. //
  5. // 5 Function Calculator
  6. //
  7. // Points: 4
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // Create the Calculator class that will allow this program to compile and execute.
  11. //
  12. ////////////////////////////////////////////////////////////////////////////////
  13. // When complete, the output should look like this:
  14. //
  15. // 1000 + 2000 = 3000
  16. // 5000 - 1037 = 3976
  17. // 1024 * 1024 = 1048576
  18. // 5000 / 1024 = 4
  19. // 5000 % 1024 = 904
  20.  
  21.  
  22. public class Prog11
  23. {
  24. public static void main (String args[])
  25. {
  26. System.out.println("1000 + 2000 = " + Calculator.add(1000,2000));
  27. System.out.println("5000 - 1024 = " + Calculator.subtract(5000,1024));
  28. System.out.println("1024 * 1024 = " + Calculator.multiply(1024,1024));
  29. System.out.println("5000 / 1024 = " + Calculator.divide(5000,1024));
  30. System.out.println("5000 % 1024 = " + Calculator.remainder(5000,1024));
  31. }
  32. }
  33.  
  34. class Calculator
  35. {
  36. public static int add(int x, int y)
  37. {
  38. return x + y;
  39. }
  40.  
  41. public static int subtract(int x, int y)
  42. {
  43. return x - y;
  44. }
  45. public static int multiply(int x, int y)
  46. {
  47. return x * y;
  48. }
  49. public static int divide(int x, int y)
  50. {
  51. return x / y;
  52. }
  53. public static int remainder(int x, int y)
  54. {
  55. return x % y;
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement