Question: write a java code String foodFields is read from input and contains multiple foods all on the same line. Assign convertedFoodFields with a copy of
write a java code String foodFields is read from input and contains multiple foods all on the same line. Assign convertedFoodFields with a copy of foodFields where all occurrences of "scallion" are replaced with "onion".
Ex: If the input is scallion, juice, scallion, then the output is:
onion, juice, onion
this is what;s given
import java.util.Scanner;
public class ReplaceStrings
public static void mainString args
Scanner scnr new ScannerSystemin;
String foodFields;
String convertedFoodFields;
foodFields scnrnextLine;
System.out.printlnconvertedFoodFields;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
