subject

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

red purple yellow
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;
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
question
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
question
Computers and Technology, 24.06.2019 12:30
Select all that apply. what two keys listed below should you use to enter data in an excel worksheet? tab backspace enter right arrow
Answers: 2
You know the right answer?
Write code that inserts userItems into the output string stream itemsOSS until the user enters "Exit...
Questions
question
Mathematics, 27.05.2020 19:01
question
Mathematics, 27.05.2020 19:01
question
Mathematics, 27.05.2020 19:01
question
English, 27.05.2020 19:01