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
Why do software developers prefer to use high-level language to author programs? A. It can be used on computers without microprocessors. B. It prevents anyone from making changes to the software later. C. It uses a more English-like syntax. D.
Answers (2)
This application software was one of the first spreadsheet products.
Answers (1)
Bob Smith is suspected of using his company's Internet facilities as a conduit for sending large quantities of SPAM to millions of users. You are called in to examine his computer to see if there is evidence to support this claim.
Answers (1)
A website that allows a company to share information in order to increase customers' know-ledge about its products, create a conversation between the firm and consumers, and provide an active forum for testing new ideas is a:
Answers (1)
function calculate () { var s = 2; var x = 2; var y = 3; if (x > 4) { s=s + 2; } else if (y > 4) { s=s + 4; } else { s+=3; } alert ("s="+s); }//close function
Answers (1)
New Questions in Computers & Technology
A collection of data elements. a-An Array b-A Cluster c-A Bundle d-A Local Variable
Answers (1)
Assume the existence of a Window class with a function getWidth that returns the width of the window. Define a derived class WindowWithBorder that contains a single additional integer instance variable named borderWidth, and has a constructor that
Answers (1)
Which feature of spreadsheet software will make it easier for you to find the average number of calls made per hour for each employee?
Answers (2)
in the lab, which domain had the greatest number of risks, threats, and vulnerabilities? a. WAN Domain b. Remote Access Domain c. LAN-to-WAN Domain d. User Domain
Answers (1)
You have added a new printer to the office. The printer is used by members of the Accounting department for printing forms and reports. The printer was not auto-detected, so you need to add the printer manually.
Answers (1)
Home
»
Computers & Technology
» Term 2 lesson 2 coding activity edhesive
Sign In
Sign Up
Forgot Password?