Answered step by step
Verified Expert Solution
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
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 changeWorkspaceString supplyData, int numRemove
int i;
Your code goes here
for i ; i result.length; i
resulti supplyDatai;
return result;
public static void mainString args
Scanner scnr new ScannerSystemin;
String helpfulSupplies new String;
int input;
int i;
for i ; i helpfulSupplies.length; i
helpfulSuppliesi scnrnext;
Read number of values to decrease array size by
input scnrnextInt;
helpfulSupplies changeWorkspacehelpfulSupplies input;
for i ; i helpfulSupplies.length; i
System.out.printhelpfulSuppliesi;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started