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
Releasing refrigerator R - 12 into the atmosphere is a criminal offense. A) true B) false
Answers (1)
What number represents the stdin file descriptor?
Answers (1)
Which statement best describes the Quick Steps feature in Outlook? It is only configured for tasks that are not frequently used. It allows a user to add multiple steps to common tasks. It allows multiple users to add commands to a single mailbox.
Answers (1)
Which organization collects consumer complaints
Answers (1)
Given an ip address 172.16.28.252 with a subnet mask of 255.255.240.0, what is the correct network address?
Answers (1)
New Questions in Computers & Technology
One of Kyle's clients called to complain that his computer was running really slow. Kyle went to the client's work area and started troubleshooting the problem. Kyle ran the Disk Defragmenter and Disk Clean-up utilities.
Answers (1)
You can click the what button to undo an automatic correction?
Answers (1)
It is generally safe to download mobile apps from unknown sources.
Answers (2)
Key issues from a software security perspective are whether the implemented algorithm correctly solves the specified problem, whether the machine instructions executed correctly represent the high level algorithm specification, and whether the
Answers (1)
What does adf stand for
Answers (2)
Home
»
Computers & Technology
» Term 2 lesson 2 coding activity edhesive
Sign In
Sign Up
Forgot Password?