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

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!