Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA L1 - Write a Java program that allows a user to input multiple words. Your program should stop accepting words when the user enters

JAVA L1 - Write a Java program that allows a user to input multiple words. Your program should stop accepting words when the user enters "STOP". Store the words in an ArrayList. The word STOP should not be stored in the list.

Next, print the size of the list, followed by the list itself.

Then, replace the last index with the first one and remove the value from the first index, but only if the list has a length greater than two. Finally, reprint the list.

Sample Run:

Please enter words, enter STOP to stop the loop. phone computer laptop television newspaper STOP 5 [phone,computer,laptop,television,newspaper] [computer,laptop, television,phone] 

Note: For this activity, you must use the class name, U7_L1_Activity_One and the method, main.

Hint: use a while loop to take the user input - remember that this type of loop runs until the condition you specify is no longer met so you can base this off the user input.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago

Question

What is IUPAC system? Name organic compounds using IUPAC system.

Answered: 1 week ago

Question

What happens when carbonate and hydrogen react with carbonate?

Answered: 1 week ago