Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

The changeWorkspace ( ) method takes in two parameters: string array supplyData and integer numRemove. Complete changeWorkspace ( ) to create a new array called

The changeWorkspace() method takes in two parameters: string array supplyData and integer numRemove. Complete changeWorkspace() to create a new array called result with the same elements as supplyData, and the size decreased by numRemove.
Ex: If the input is:
pencil envelope ruler
1
then the output is:
pencil envelope
Note: Assume numRemove is less than the length of supplyData. import java.util.Scanner;
public class Workspace {
public static String[] changeWorkspace(String[] supplyData, int numRemove){
int i;
/* Your code goes here */
for (i =0; i < result.length; ++i){
result[i]= supplyData[i];
}
return result;
}
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
String[] helpfulSupplies = new String[3];
int input;
int i;
for (i =0; i < helpfulSupplies.length; ++i){
helpfulSupplies[i]= scnr.next();
}
// Read number of values to decrease array size by
input = scnr.nextInt();
helpfulSupplies = changeWorkspace(helpfulSupplies, input);
for (i =0; i < helpfulSupplies.length; ++i){
System.out.print(helpfulSupplies[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_2

Step: 3

blur-text-image_3

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students explore these related Databases questions