Question
{Create the following program in Java (As simple as possible) Do not use StringBuilder etc. a. Write code to fill an array evens with the
{Create the following program in Java (As simple as possible) Do not use StringBuilder etc.
a. Write code to fill an array evens with the following set of integers. You must use a loop.
0 2 4 6 8 10 12 14 16 18 20
b. Write code to fill an array squares with the following set of integers. You must use a loop.
1 4 9 16 25 36 49 64 81 100
c. Create an array named 'finalGrade' to store the following elements:
{85.8, 93.7, 76, 88.5, 100, 91.3}
Write a void method named calcAverage which takes the array as a parameter. Use a loop in this method to calculate and print the average of the values to the nearest hundredth.
d. Create an array to store 10 random integers between 1 and 10. Write a void method named printArray which uses a for-each loop to print the array. Write another method named printArrayBackwards which uses a for loop to print the array backwards! Finally, count and print the total number of even numbers in the array.
e. Create an array to store the ages of 20 people. Ask the user to enter the ages at the keyboard. The prompts should be: Enter age #1: and should continue as such for all 20 entries. After creating the array, write a method to count and print the total number of ages in the array that is greater than 15.
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