Sign In
Ask Question
Computers & Technology
Guest
4 June, 21:09
Term 2 lesson 2 coding activity edhesive
+2
Answers (
1
)
Krause
4 June, 23:32
0
We need to write a program, that allows the input of words, and it stops when we enter the word "STOP". And it should not save the word STOP, and print the rest of the previous words in the form of a sentence.
Explanation:
import java. io.*;
import java. util. Scanner;
import java. util. ArrayList;
import java. lang. Math;
class Main
{
public static void main (String args[])
{
Scanner s1 = new Scanner (System. in);
ArrayList sentence1 = new ArrayList ();
System. out. println ("Enter the sentence, and input word STOP to stop entering:");
while (0==0)
{
String s2 = s1. nextLine ();
if (s2. equals ("STOP"))
{
break;
}
else
{
sentence1. add (s2);
}
}
for (String q1: sentence1)
{
if (q1. contains ("a"))
{
System. out. println (q1);
}
}
}
}
We create an array list here, and a string type variable to store words. We allow the user to enter the words, and we stop them when they input the word STOP. And we store all other words other than STOP in the sentence1 ArrayList, and finally, print them out as a sentence.
Comment
Complaint
Link
Know the Answer?
Answer
Not Sure About the Answer?
Get an answer to your question ✅
“Term 2 lesson 2 coding activity edhesive ...”
in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers
You Might be Interested in
Enables businesses and consumers to share data or use software applications directly from a remote server over the Internet or wirelessly rather than having that data file or program reside on a personal computer
Answers (1)
The title element configures large, bold text at the beginning of the web page document. a. True b. False
Answers (1)
Betty is photographing a meadow at 1:00 p. m. What camera white balance setting will work best at this time? A. Flash B. Daylight C. Fluorescent D. Cloudy
Answers (1)
TV stations in the U. S. normally broadcast horizontally-polarized signals. Is this TV antenna mounted correctly, or should it be rotated?
Answers (1)
Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to take approximately 20 minutes to run individually. However, he would like to go to lunch 15 minutes from now.
Answers (1)
New Questions in Computers & Technology
How have productivity programs improved the professional lives of people? (check all that apply) o made it easier and faster to communicate with others made it harder to create and modify documents made it easier to manipulate numbers in a
Answers (2)
Why should we use a markup language to create basic web pages to be interpreted by the web browser?
Answers (1)
Which key moves a cursor to the beginning of a line?
Answers (1)
Write a function named "read_json" that takes a JSON formatted string as a parameter and return the data represented by the input in the appropriate types for this language.
Answers (1)
Can you know what time someone retweeted
Answers (1)
Home
»
Computers & Technology
» Term 2 lesson 2 coding activity edhesive
Sign In
Sign Up
Forgot Password?