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
Which of the following is commonly inserted in ten header of a document? A. Title of the document B. Summary of the document C. Table of contents
Answers (2)
Social engineering is deceiving or using people to get around security controls. True False
Answers (1)
Why does my phone work faster when it cold?
Answers (1)
What is one reason why business ethics are important? a.) To enforce regular exercise among employees b.) To profit from dishonest transactions c.) To promote suspicious behavior in the workplace d.) To stay within the law
Answers (1)
Suppose Animal is an interface that specifies a single method - speak. Now suppose the Dog class implements the Animal interface. In addition to the speak method, the Dog class also has a method called wagTail. Now consider the following code.
Answers (1)
New Questions in Computers & Technology
Samuel needs to import information from Excel to an Access table, but he wants to ensure that if the source table is changed, the information in Access will be updated automatically.
Answers (1)
Is task location less important than task language?
Answers (2)
which of these describe raw data? check all of the boxes that apply A) what a person buys B) where a person lives C) data that has been analyzed D) data that has not been analyzed
Answers (1)
Wikipedia is an example of which version of the Web
Answers (2)
How does hardware differ from software? Hardware can be an external tool, whereas software is an internal tool. Hardware performs tasks, whereas software provides instructions. Hardware runs the computer, whereas software performs tasks.
Answers (1)
Home
»
Computers & Technology
» Term 2 lesson 2 coding activity edhesive
Sign In
Sign Up
Forgot Password?