Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. /*
  2. * The following program has been started,
  3. * but is incomplete. Write your code for
  4. * each of the methods, one at a time,
  5. * then test them to see if they work.
  6. * Use an online java compiler to test
  7. * your code by pasting the code on
  8. * https://www.jdoodle.com/online-java-compiler
  9. * Make sure to delete everything they wrote on
  10. * the screen first before pasting yours in.
  11. */
  12.  
  13. public class MyClass
  14. {
  15. public static void main(String args[])
  16. {
  17. //Leave this method alone.
  18. stars(1); num1();
  19. stars(2); num2();
  20. stars(3); num3();
  21. stars(4); num4();
  22. stars(5); num5();
  23. stars(6); num6();
  24. }
  25.  
  26. public static void num1()
  27. {
  28. //Use a for loop to print the following repetive song lyrics
  29. //10 times in a row. The lyrics to print are:
  30. //"I, I, I shake it off, I shake it off"
  31. //Make sure to count it actually happened 10 times, not 9 or 11.
  32. }
  33.  
  34. public static void num2()
  35. {
  36. //Use a while loop to print the
  37. //numbers 100 to 1 in the following way:
  38. //100
  39. //50
  40. //25
  41. //12
  42. //6
  43. //3
  44. //2
  45. //1
  46.  
  47. //Notice the numbers are constantly being cut in half
  48. }
  49.  
  50. public static void num3()
  51. {
  52. //Slight modification of num2
  53. //Use a while loop to print the
  54. //numbers 1600 to 0 in the following way
  55. //1600
  56. //800
  57. //400
  58. //200
  59. //100
  60. //50
  61. //25
  62. //12
  63. //6
  64. //3
  65. //1
  66. //0
  67. }
  68.  
  69. public static void num4()
  70. {
  71. //Print 10 random dice rolls - {1,2,3,4,5,6}
  72. //Use a for loop
  73. }
  74.  
  75. public static void num5()
  76. {
  77. //Print the numbers 1 through 50, but
  78. //print even or odd next to each number
  79. //depending on what it is.
  80. //Use a for loop.
  81.  
  82. //1 odd
  83. //2 even
  84. //3 odd
  85. //4 even
  86. //5 odd
  87. //...
  88. //50 even
  89. }
  90.  
  91. public static void num6()
  92. {
  93. //Make an x y chart to model the
  94. //equation y = 5x^2 - 3x + 10
  95. //Let x go from 1 to 10, then use
  96. //x to calculate y.
  97. //Use the Math.pow method to do the ^2
  98. //Begin by print just "x" and "y" with a
  99. //tab between. Then start your loop.
  100. //Use a tab to separate the two columns.
  101. //Use a for loop.
  102.  
  103. //Your output should look like this:
  104. //x y
  105. //0 10
  106. //1 12
  107. //...
  108. //10 480
  109. }
  110.  
  111. public static void stars(int num)
  112. {
  113. //Leave this one alone.
  114. System.out.println( "******* " + num + " *******" );
  115. }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement