Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that will perform the steps described below. Your program should perform these steps in the order specified. In each case, if
Write a Java program that will perform the steps described below. Your program should perform these steps in the order specified.
In each case, if you are asked to display an answer/value, do it in a complete sentence. For instance to display the number of states in the US, you would display: The number of states in the US is 50 (or something similar) If you are not asked to display the answer, that step does not need to output anything.
1) Using a for loop, display the numbers from 1 to 10, one per line. 2) Using a for loop, display the numbers from 10 to 1, one per line, with each number followed by an exclamation point. 3) For your nerdy amusement, display the the string "Blastoff!!!". =) 4) Use an array initializer to declare and initialize an array called "numbers" that initially contains the values 11, 8, -7, 22, 3, -17, 6, 25, 10, 5, -12, -9, 14, 20, -13 5) Display (one per line) the elements of the array "numbers". 6) Using a for loop, display the numbers from 0 to 10, counting by two. 7) Display the elements in the "numbers" array that are even numbers. 8) Display the elements in the "numbers" array that reside at even indexes. 9) Display the elements in the "numbers" array that are negative. 10) Display the elements in the "numbers" array that are multiples of 5. 11) Calculate and display the sum of all of the values in the numbers array. 12) Find the largest element in the "numbers" array. Save the largest value in a variable named "largestNum". Save the index of the largest value in "indexLargestNum" 13) Display "largestNum" and "indexLargestNum". 14) For each element in "numbers", display whether the element is a) less than -15 b) between -15 and 15 c) greater than 15 15) Rewrite the following piece of code using a "while loop": for (i=50; i>25; i-=5) System.out.println("i = " + i);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started