1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Hoochie [10]
3 years ago
14

Java 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
Computers and Technology
2 answers:
Step2247 [10]3 years ago
4 0
If you're a zybooks user.

itemsOSS.print(userItem + " "); 
      userItem = itemCharStream.toString();
GenaCL600 [577]3 years ago
4 0

For the given problem, first read the input from console using scanner class. Then print the input into the print writer and scan the next word using the scanner. This will continues until we did not get ‘Exit’ word. The loop will terminate when user enter exit. Now, append the text and print the string.  

Further Explanation:  

Code: The below Java code that inserts the user items into output stream items until the user enters “exit”.  

// Scanner class to take input from the keyboards

import java.util.Scanner;  

//Enables to find the characters written to a writer as a string

import java.io.StringWriter;  

// Used to print the objects in text-output stream

import java.io.PrintWriter;  

//class definition

public class UserInputsOutputs

{  

   public static void main (String [] args)  

   {  

//Scanner class to read the input  

        Scanner scan = new Scanner(System.in);  

        String userItem = "";  

// printwriter to print items on the console.  

        StringWriter itemCharStream = new StringWriter();  

        PrintWriter stringItems = new PrintWriter(itemCharStream);  

        System.out.println("Enter items (type Exit to quit):");  

        userItem = scan.next();  

// Loop terminates when user enter Exit  

        while (!userItem.equals("Exit"))  

        {  

            stringItems.append(userItem+" ");  

            userItem = scan.next();  

        }  

        userItem = itemCharStream.toString();  

// Display the string  

        System.out.println(userItem);  

        return;  

   }  

}  

Learn more:  

1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011    

2. Prediction accuracy of a neural network depends on _______________ and ______________. brainly.com/question/10599832    

3. The shape of our galaxy was determined ‘on the inside looking out' by surveying the milky way using ____________ telescopes. brainly.com/question/7866623  

Answer details:  

Grade: College Engineering  

Subject: Computer Science and Engineering  

Chapter: Java Programming  

Keyword:  

Java, programming, console, user, items, string, append, string, writer, scanner, input, output, red, purple, yellow, stream, print, next, loop, while, for, if else statement, println  

You might be interested in
why do programs include keyboard shortcuts for certain actions? do you prefer the mouse or the keyboard/ why?
Archy [21]
I would prefer the shortcut because it would make it easier to open tabs and close them too. but the can also help you with other stuff to .
4 0
4 years ago
1. Paying attention to the trends that might impact your future career is called
amm1812
The answer is A futurecasting.
8 0
4 years ago
Read 2 more answers
Swiping and pinching are graphical user interface (gui) _____________.
Sergeu [11.5K]
Swiping and pinching are graphical user interface (gui) to zoom in or zoom out.  <span>One of the many multitouch gestures on today's laptops is the ability to </span>pinch<span> two fingers to </span>zoom<span> in and </span>out<span> in a window. </span>
6 0
4 years ago
Read 2 more answers
Complete the sentence with the correct response. In a two-way selection, if the initial statement is evaluated as , the code ski
mestny [16]

Answer:

True.

The code skips the else command

Explanation:

I will answer this question with the following code segment

<em>n = 1</em>

<em>If n > 0:</em>

<em>   Print("greater than 0")</em>

<em>else:</em>

<em>   Print("not greater than 0")</em>

<em />

From the code segment above

<em>Print("greater than 0")</em> will be executed because the condition <em>If n > 0 </em>is true

Since the if condition is true, the else condition will not be executed

8 0
3 years ago
A normal lens has
nekit [7.7K]
It has a larger field of view
8 0
3 years ago
Other questions:
  • Write a paragraph on the importance of backing up data and mention at least three ways to back up data from your computer.
    15·1 answer
  • The hotspot created by MiFi is password protected and can be used to connect Wi-Fi devices located within ____ feet of the MiFi
    9·1 answer
  • How many iterations for each for-loop where max = 10 and incr = 3 a. for (int i = 0; i &lt; max; i++) b. for (int i = 0; i &lt;
    13·1 answer
  • Adding all the three primary colors-red, green, and blue-at maximum intensity produces the color _____, while adding any two of
    9·1 answer
  • Tom installs a Telnet application on his Windows Vista system. When he first starts the program, Windows Firewall pops up with a
    10·1 answer
  • During side show mode, hitting the B key will do which one of these?
    7·1 answer
  • Plz I’ll mark Brainliest
    7·1 answer
  • In Python in order for a sort to work, which of the following is required?
    14·2 answers
  • Which among the following if absent, a computer is not complete.
    6·2 answers
  • What are some benefits that each computer system being used?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!