Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!