Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

cheak the code my output Please enter words, enter STOP to stop the loop. cup spoon fork bowl plate knife STOP 6 [cup, spoon, fork,

cheak the code

my output

Please enter words, enter STOP to stop the loop. cup spoon fork bowl plate knife STOP 6 [cup, spoon, fork, bowl, plate, knife] [spoon, fork, bowl, plate] 

the code

import java.util.ArrayList; import java.util.Scanner;

public class Main {

public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Please enter words, enter STOP to stop the loop: "); String s = ""; ArrayList list = new ArrayList(); s = scan.next(); while(!s.equalsIgnoreCase("STOP")){ list.add(s); s = scan.next(); } System.out.println(); System.out.println(list.size()); System.out.println(list); if(list.size()>2){ list.remove(0); list.remove(list.size()-1); System.out.println(list); } }

}

Your code has been evaluated against a set of test data. You had 15 out of 18 tests pass correctly. Your score is 83%. Test#1:16 Gs Case #1 passed Case #2 passed Case #3 passed Test#2:same word Case #1 passed Case #2 passed Case #3 passed Test#3:2 words Case #1 passed Case #2 passed Case #3 passed Test#3:1 word Case #1 passed Case #2 passed Case #3 passed Test#4:0 word Case #1 passed Case #2 passed Case #3 passed Test#5:stop word Case #1 failed Case #2 failed Case #3 failed 

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions