Question: Write the following into a java program: (Java Class) All of these can be in one program if you like. Indicate in comments which part
Write the following into a java program: (Java Class)
All of these can be in one program if you like. Indicate in comments which part youre doing, eg. // Part II C
Write a while loop that outputs the numbers from 1 to 25 on one line. Use System.out.print( )
Write a while loop that outputs the multiples of 7 that are less than or equal to 125.
Write a for loop that sums up the numbers in the range 234 19348 inclusive. Output the result. Use a Java style for loop, not a C style loop. Hint: Try making a loop that adds a small range of numbers, maybe 7 11, your answer should be 7 + 8 + 9 + 10 + 11. When you get that working, change back to the specified range.
Write a sentinel controlled while loop that asks the user for an int value, and continues to ask for another int value until the user enters -999. Do not use break. Output the sum of the numbers that the user entered, excluding the sentinel value. Test your program with 10, 20, 30, -999. The answer should be 60.
Write a loop that outputs all the powers of 2 that will fit in a long variable. 1, 2, 4, 8, 16
Notice that you can start with 1, and double it each time to get the next value.
2 to the power of 0 is 1
2 to the power of 1 is 2
2 to the power of 2 is 4
2 to the power of 3 is 8
..etc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
