Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program using Seafiner and its nexll ine method. The following is an exampie of how to use nexil ine Scanner hybd = new

image text in transcribed
image text in transcribed
image text in transcribed
Write a program using Seafiner and its nexll ine method. The following is an exampie of how to use nexil ine Scanner hybd = new Seanner(Syshem in). System out printlenf Enter a line of fext? String aline a kybd nexilined. If the user's input is stiorter than 7 characters, print the mesmage "The input is too short" and do no further processing- If the user's input is 7 characters or longer, perform the following operations. Print either "the original string has no leading or trailing whitespace" or "the original String has leading or trailing whitespace." (Hint: the trim method will be a good start, but you'll need more.) Swap the first two and last five characters of aline and print the result. Print aline in all upper case. If atine has an odd number of characters, print. "The line has an odd number of characters." otherwise, print the two middle characters of aline. Print the compare fo results of comparing atine in all lower case with the original at une. (This will be a rumber.) Print whether the first half of atine is the same as the last half of ak ine except for case. Print aLme with one character removed: The first' 'e' ' E ' 'e' or' 5 '. Note: treat each of these steps as an independent action optrating on the original input. So If the original input wasi. kilroy was here, ntill walting for godot. iswapping the first two and last five characters would print Print aline with one character removed: The first 'e' ' E ' 's' or ' S. Note: treat each of these steps as an independent action operating on the orlginal input. So if the originat input was kitroy was here, still waiting for godot swapping the first two and last five characters would print godotiroy was here, still waiting for kl and printing the input in all upper case would result in KILROY WAS HERE, STLL WATTING FOR GODOT You may use ONLY String's indexOf, charAt, length, comparefo, toUpperCase, totowerCase, trim, equats, equalsignoreCase and substring methods. Enter a line of text: This line starts with a blank The original string has leading or trailing whitespace First 2 and last 5 chars swapped: blankhis line starts with a T to upper case: THIS LINE STARTS WITH A BLANK The two middle characters are rt compareTo lower case version: 32 Does the fist half equal the last half? false the input with first ' e " or ' E ' or ' s ' or ' 5 ' removed: Thi line starts with a blank Enter a line of text: Kilroy was here, still waiting for Godot The original string has no leading or trailing whitespace First 2 and last 5 chars swapped: Godotlroy was here, still waiting for Ki to upper case: KILROY WAS HERE, STILL WAIIING FOR GOOOT The two middle characters are il compareto lower case version: 32 Does the fist half equal the last half? false the input with first ' e ' or ' E ' or ' s ' or ' 5 ' removed: Kilroy wa here, still waiting for Godot

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

5. Structure your speech to make it easy to listen to

Answered: 1 week ago

Question

1. Describe the goals of informative speaking

Answered: 1 week ago