Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need java code for this , The following question has two test cases , I want the Test cases (strings) executed directly from program also

Need java code for this , The following question has two test cases , I want the Test cases (strings) executed directly from program also simultaneously , dont give me System.out.println("Enter the string")

because I cant type any input in output console .and my test case will fail .

There is already code in the image , if you can modify it or write a new code. I just want those 2 strings executed giving ,me output : "Some" for test case 1 and " another" for testcase2image text in transcribedimage text in transcribed

Programming challenge description: In this challenge you need to find the longest word in a sentence. If the sentence has more than one word of the same length you should pick the one that appears first. Input: Your program should read Unes from standard input. Each line has one or more words. Each word is separated by a space char. Output: Print the longest word in the sentence. Test 1 Test Input some line with text Expected Output some Test 2 Test Input another line Expected Output another 58 59 import java.util.Arrays; 60 public class Main 61 { 62 public static void main(String[] args) { 63 String sInputStr = "some line with text"; 64 65 ProcessString Operation(sInputStr); 66 } 67 68 public static void ProcessStringOperation(String sInputStr) 69 70 String[] words = sInputStr.split(" "); 71 String[] finalWork = sInputStr.split(" ");; 72 73 Arrays.sort(words, (x,y)->Integer.compare(x.length(),y.length())); 74 String sArray = Arrays.deepToString(words).split(",")[words.length-1]; 75 sArray =sArray.replace( sArray.substring(sArray.length()-1), ""); 76 77 for (int i=0; i _ Test Case Output Running test cases... Done

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: 3

blur-text-image

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago