Untitled


SUBMITTED BY: Guest

DATE: Sept. 11, 2014, 10:37 p.m.

FORMAT: Text only

SIZE: 5.6 kB

HITS: 764

  1. /**
  2. * The Calculations class performs addition, subtraction,
  3. * multiplication, division, and modulus operations on integers and
  4. * decimals.
  5. *
  6. * �FLVS 2014
  7. * @author Christian Lockley
  8. * @version V5
  9. */
  10. public class CalculationsV5
  11. {
  12. public static void main(String[] args)
  13. {
  14. double dpi = 3.14;
  15. //const int i9 = 9; //google the java equivalent
  16. int i9 = 9;
  17. int i25 = 25;
  18. double d5 = 5.0;
  19. double dp5 = .5;
  20. int i50 = 50;
  21. int i16 = 16;
  22. int i3 = 3;
  23. int i15 = 15;
  24. int i10 = 10;
  25. int i5 = 5;
  26. int i11 = 11;
  27. int i12 = 12;
  28. int i20 = 20;
  29. int i8 = 8;
  30. int i2 = 2;
  31. int i6 = 6;
  32. int ni2 = i2 * -1;
  33. double d2p5 = 2.5;
  34. int i24 = 24;
  35. double d43p21 = 43.21;
  36. // Addition
  37. System.out.println("Addition");
  38. System.out.print(i25 + "plus " + i9 + " equals ");
  39. System.out.println(i25 + i9 );
  40. System.out.print(d43p21 + " minus " + dpi + "plus " + d5 + " equals ");
  41. System.out.println(d43p21 + dpi + d5);
  42. System.out.println();
  43. // Subtraction
  44. System.out.println("Subtraction");
  45. System.out.print( i16 + " minus " + i9 + " minus " + i25 + " equals ");
  46. System.out.println(i16 - i9 - i25);
  47. System.out.println();
  48. System.out.println(dpi + " minus " + dp5 + " equals ");
  49. System.out.print(dpi - d5);
  50. System.out.println();
  51. // Multiplication
  52. System.out.println("\nMultiplication");
  53. System.out.print(i25 + " times " + i9 + " equals ");
  54. System.out.println(i25 * i9);
  55. System.out.print(dpi + " times " + i50 + " times " + dp5 + " equals ");
  56. System.out.println(dpi * d5 * d5);
  57. System.out.println();
  58. // Division
  59. System.out.println("Division");
  60. System.out.print(i9 + " divided by " + i25 + " equals ");
  61. System.out.println(i9 / i25);
  62. System.out.print(d43p21 + " divided by " + dp5 + " equals ");
  63. System.out.println(d43p21 + " divided by " + d5);
  64. System.out.println();
  65. // Modulus operator
  66. System.out.println("Modulus");
  67. System.out.print(i16 + " mod " + i9 + " equals ");
  68. System.out.println(i16 % i9);
  69. System.out.print(dp5 + " mod " + dpi + " equals ");
  70. System.out.print(d5 % dpi);
  71. System.out.println();
  72. System.out.println();
  73. System.out.println("2.02 Lab Equations");
  74. System.out.print(i15 + " divided by " + d2p5 + " times " + ni2 + " plus " + i10 + "/" + i5 + " equals ");
  75. System.out.println(i15 / d2p5 * ni2 + i10 / i5);
  76. int i234 = 234;
  77. System.out.print(i234 + " minus " + "(" + i234 + " divided by " + i6 + " modulus " + i12 + ")" + i3 + " equals ");
  78. System.out.println(i234 - (i234 / (i6 % i12)) + i3);
  79. int i17 = 17;
  80. double d46p2 = 46.2;
  81. System.out.print("(" + d46p2 + " divided by " + i11 + ") minus " + i3 + " plus " + i24 + " modulus ( "+i17 + " minus " + i2 + "times " + i3 + ") equals ");
  82. System.out.println((d46p2 / i11 - i3) + i24 % (i17 - i2) * i3);
  83. // 480 divided by 10 divided by 12 plus 200 *.5 minus 20 modulus 8
  84. int i480 = 480;
  85. int i200 = 200;
  86. System.out.print(i480 + " divided by " + i10 + " divided by " + i12 + " plus " + i200 * dp5 + " minus " + i20 + " modulus 8 equals ");
  87. System.out.println(((i480 / i10) / i12) + i200 * dp5 - (i20 % i8));
  88. System.out.println("\n2.03 Additional int Equations");
  89. System.out.println("");
  90. final int equatone = 128 * 256 % 512 + 1024 / 4 - 128;
  91. final int i128 = 128;
  92. final int i256 = i128 * 2;
  93. final int i512 = i256 * 2;
  94. final int i1024 = i512 * 2;
  95. System.out.println("\n"+ i128 +" times "+ i256+ " mod " + i512 + " plus " + i1024 + " divided by " + i5 + " minus " + i128 + " equals " + equatone);
  96. final int i1 = 1;
  97. System.out.print("(((("+i8+" minus "+i2+") plus "+ i1 +") times " + i5+") mod "+i2 +") equals ");
  98. System.out.println( ((((8 - 2) + 1) * 5 % 2)));
  99. System.out.println("");
  100. System.out.println("2.04 Additional double Equations");
  101. System.out.println("");
  102. double den = 2.7;
  103. int i14 = 14;
  104. int i4 = 4;
  105. System.out.println(dpi + " times " + den + " times " + i8 + " divided by " + i4 + " minus " + i14 + i1 + " equals ");
  106. System.out.println(dpi * den * i8 / i4 - i14 + i1);
  107. System.out.println("");
  108. double grat = 1.61;
  109. System.out.println(dpi + " plus " + grat + " times " + i8 + " divided by " + i4 + " minus " + i14 + " plus " + ni2 + " times " + i480 + " times " + grat + " equals");
  110. System.out.println(dpi * grat * i8 / i4 - i14 + ni2 * i480 * grat);
  111. } // end of main method
  112. } // end of class

comments powered by Disqus