Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I modify the following java code? 1. Need to add 2 elements to the array 2.Need to modify it WITHOUT just changing the

How do I modify the following java code?

1. Need to add 2 elements to the array

2.Need to modify it WITHOUT just changing the input statement from "Enter five positive numbers...." to" Enter seven positive numbers.... "

3. And still have to call the modify method

4.ADD new print statement that says "The new array list of square roots are:"

import java.util.Scanner; public class DiscWeek7 { public static void modify (double values[]) { for (int i = 0; i < values.length; i++) { values[i] = (Math.sqrt(values[i])); } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); double values[] = new double[5]; System.out.println("Enter five positive numbers separated by spaces to see their square roots."); for (int i = 0; i < values.length; i++) { values[i] = scan.nextDouble(); } modify(values); System.out.println("The square roots are:"); for (int i = 0; i < values.length; i++ ) { System.out.print(values[i] + " "); } scan.close(); } }

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Define Management by exception

Answered: 1 week ago