We store cookies data for a seamless user experience. To know more check the Privacy Policy
19+ Users Viewed
3+ Downloaded Solutions
California, US Mostly Asked From
Write code that inserts userItems into the output string stream itemsOSS until the user enters "Exit". Each item should be followed by a space. Sample output if user input is "red purple yellow Exit":
_________________________________________________________________________
import java.util.Scanner; import java.io.PrintWriter; import java.io.StringWriter;
public class StringStreamOutput { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userItem = "";
StringWriter itemCharStream = new StringWriter(); PrintWriter itemsOSS = new PrintWriter(itemCharStream);
System.out.println("Enter items (type Exit to quit):"); userItem = scnr.next();
while (!userItem.equals("Exit")) {
/* Your solution goes here */
userItem = scnr.next(); }
userItem = itemCharStream.toString(); System.out.println(userItem);
return; } }
_____________________________________________________________________________
(Hide this section if you want to rate later)
Was the final answer of the question wrong?
Were the solution steps not detailed enough?
Was the language and grammar an issue?
Does the question reference wrong data/reportor numbers?
Stay Solved :)
Get plagiarism-free solution within 48 hours
Review Please
Rate this solution on a scale of 1-5 star
Java Code: import java.io.PrintWriter; import java.io.StringWriter; import java.util.Scanner; public class StringStreamOutput { public static void main(String[] args) {...
Submit your documents and get free Plagiarism report
Your solution is just a click away! Get it Now
Get it solved from our top experts within 48hrs!