Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java built-in String class (see String (Java SE 11 & JDK 11 ) (oracle.com) for documentation) includes several very useful text processing methods. Your task

Java built-in String class (see String (Java SE 11 & JDK 11 ) (oracle.com) for documentation) includes several very useful text processing methods. Your task is to use them to complete the class below (replace with code). All missing code should be implemented using String class methods. Sample input output combinations are provided below.

Java StringProcessing class

import java.util.Scanner;

public class StringProcessing {

public static void main (String [] args){

// declare input String variable and set it to an empty string

String input = "";

// Set up the Scanner object

Scanner myScanner = new Scanner(System.in);

// Prompt the user for input:

System.out.println("Enter a line of text: ");

input = myScanner.nextLine();

System.out.println("You entered: " + input);

String inputAllLower = //[0.2 pt]

String inputAllUpper = //[0.2 pt]

System.out.println("Your input in lowercase: " + inputAllLower);

System.out.println("Your input in UPPERCASE: " + inputAllUpper);

System.out.println("Five leftmost characters in your input: " + ); //[0.6 pt]

System.out.println("Five rightmost characters in your input: " + ); //[1 pt]

System.out.println("Substring 'cs116' is located at index : " + ); //[1 pt]

System.out.println("Your input AFTER replacing substring 'cs116' with 'class' : " + ); //[1 pt]

// We don't need the Scanner object anymore - close

myScanner.close();

}

}

Here are some sample outputs:

Sample output A:

Enter a line of text:

This cs116 is a required course

You entered: This cs116 is a required course

Your input in lowercase: this cs116 is a required course

Your input in UPPERCASE: THIS CS116 IS A REQUIRED COURSE

Five leftmost characters in your input: This

Five rightmost characters in your input: ourse

Substring 'cs116' is located at index : 5

Your input AFTER replacing substring 'cs116' with 'class' : This class is a required course

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions