Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * The following program has been started,
- * but is incomplete. Write your code for
- * each of the methods, one at a time,
- * then test them to see if they work.
- * Use an online java compiler to test
- * your code by pasting the code on
- * https://www.jdoodle.com/online-java-compiler
- * Make sure to delete everything they wrote on
- * the screen first before pasting yours in.
- */
- public class MyClass
- {
- public static void main(String args[])
- {
- //Leave this method alone.
- stars(1); num1();
- stars(2); num2();
- stars(3); num3();
- stars(4); num4();
- stars(5); num5();
- stars(6); num6();
- }
- public static void num1()
- {
- //Use a for loop to print the following repetive song lyrics
- //10 times in a row. The lyrics to print are:
- //"I, I, I shake it off, I shake it off"
- //Make sure to count it actually happened 10 times, not 9 or 11.
- }
- public static void num2()
- {
- //Use a while loop to print the
- //numbers 100 to 1 in the following way:
- //100
- //50
- //25
- //12
- //6
- //3
- //2
- //1
- //Notice the numbers are constantly being cut in half
- }
- public static void num3()
- {
- //Slight modification of num2
- //Use a while loop to print the
- //numbers 1600 to 0 in the following way
- //1600
- //800
- //400
- //200
- //100
- //50
- //25
- //12
- //6
- //3
- //1
- //0
- }
- public static void num4()
- {
- //Print 10 random dice rolls - {1,2,3,4,5,6}
- //Use a for loop
- }
- public static void num5()
- {
- //Print the numbers 1 through 50, but
- //print even or odd next to each number
- //depending on what it is.
- //Use a for loop.
- //1 odd
- //2 even
- //3 odd
- //4 even
- //5 odd
- //...
- //50 even
- }
- public static void num6()
- {
- //Make an x y chart to model the
- //equation y = 5x^2 - 3x + 10
- //Let x go from 1 to 10, then use
- //x to calculate y.
- //Use the Math.pow method to do the ^2
- //Begin by print just "x" and "y" with a
- //tab between. Then start your loop.
- //Use a tab to separate the two columns.
- //Use a for loop.
- //Your output should look like this:
- //x y
- //0 10
- //1 12
- //...
- //10 480
- }
- public static void stars(int num)
- {
- //Leave this one alone.
- System.out.println( "******* " + num + " *******" );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement