Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is a Java program already coded and the requirement to help you understand. Kindly look at the already provided script and write a program

Below is a Java program already coded and the requirement to help you understand. Kindly look at the already provided script and write a program different to the one provided but will function exactly as required in the requirement. Thank you.

Given code to be modified.

public class Main {

public static void main(String[] args) {

// We need Array to store 25 number so declare three arrays of size 25

float[] firstArray = new float[25];

// fill First array with loop counter i.e from 0 to 24

for (int i = 0; i < 25; i++) {

firstArray[i] = i;

}

float[] secondArray = new float[25];

// fill second array with loop counter square i.e from 0 to 24

for (int i = 0; i < 25; i++) {

secondArray[i] = i * i;

}

float[] thirdArray = new float[25];

// fill third array to add corresponding elements in firstArray and secondArray

for (int i = 0; i < 25; i++) {

thirdArray[i] = firstArray[i] + secondArray[i];

}

// Display the Output

for (int i = 0; i < 25; i++) {

System.out.println(

"For counter " + i + "; " + firstArray[i] + " + " + secondArray[i] + " = " + thirdArray[i]);

}

}

}

The requirement to help you understand what needs to be done.

Write a java program that creates three floating point arrays. Fill the first two arrays with 25 floating point numbers using loop structures, as follows: fill the first array with the loop counter value and fill the second array with the loop counter value squared. Finally, write a loop that adds the corresponding elements in the first two arrays and puts the result in the corresponding element of the third array. Display all three arrays using the format for counter; element + element = element.

I will appreciate it if you document code changes and observations as in-line comments, and excerpts so that I will understand everything. Please write as many words explaining in detailed how you did this, preferably inline comments for everything. Thank you.

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

How are the concepts of materiality and cost-benefit related?

Answered: 1 week ago

Question

Define Administration and Management

Answered: 1 week ago