Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PF1 Lab4 Write a Java program that will perform the steps described below. Your program should perform these steps in the order specified. Put your

PF1 Lab4 Write a Java program that will perform the steps described below. Your program should perform these steps in the order specified. Put your lab in the file ~/PF1/lab4/Lab4.java 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. Assume the questions are cumulative. IE any change made in one step will affect the following steps. If you want/need to declare/use variables that I did not mention, do so. Please add comments, etc to your code so I can tell what problem number each line (or section) of code solves. You should write, debug and compile this program, leaving the ".class" file in your directory so that I can run your program to verify it. I'll grade online and leave comments/grade in a file named README.MCU ========================================================================= 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What is the spectator role?

Answered: 1 week ago

Question

Define organization development (OD)

Answered: 1 week ago