Answered! Write a program that accepts a paragraph of text that can be manipulated. The resulting manipulated text will output…

Write a program that accepts a paragraph of text that can be manipulated. The resulting manipulated text will output to the console.

Constraints

 The user should input a paragraph of text such as a famous quote

 The program repeats the paragraph before displaying the following menu of options:

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

Requirements

 All printed results should use formatted output (Do not use ‘+’ in your output statements)

 Use a switch/case block of code that will act on each menu option

 Use line break escape sequences with your formatting escape sequence to format your output as shown in the examples below

 For menu option 4, the questions should also use formatted output and the upper limit should use the .length() method in the first question

 Use the Math.random() method and formatted output for menu option 5

 This program will utilize code learned from Week 1 through Week 4

Hints

 For menu option 5, you might want to consider finding the second random limit before finding the first. The second limit (the end limit) may come in handy for your lower limit formatted output line. Think ‘length’ when finding the upper limit

 Use System.exit(0); to properly exit the program if a choice or default option fires

Expected Output

Below you will find sample output for each menu option. User input is in BOLD.

Sample Output

Menu Option 1:

Please enter a paragraph of text

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered:

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 1

Your paragraph in all uppercase letters

: FOUR SCORE AND SEVEN YEARS AGO OUR FATHERS BROUGHT FORTH ON THIS CONTINENT, A NEW NATION, CONCEIVED IN LIBERTY, AND DEDICATED TO THE PROPOSITION THAT ALL MEN ARE CREATED EQUAL.

Menu Option 2:

Please enter a paragraph of text

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 2

Your paragraph in all lowercase letters:

four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.

Menu Option 3:

Please enter a paragraph of text

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered:

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 3

The length of your paragraph is: 176 characters & spaces.

Menu Option 4:

Please enter a paragraph of text

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered:

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 4

Select a starting point between 0 and 176: 39

Select a starting point between 39 and 176: 141

The substring you selected is:

ers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposit

Menu Option 5:

Please enter a paragraph of text

:Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered:

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 5

Random selected a starting point of: 9

And an ending point of: 113

Your Random substring is:

e and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, a

Menu Option 6:

Please enter a paragraph of text

: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

You entered:

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Please choose from the following menu of options:

1. Convert to all uppercase letters

2. Convert to all lowercase letters

3. Display the length of the paragraph

4. Select a substring from the paragraph

5. Let Random select a substring from the paragraph

6. Exit

: 6

Thank you for using the program. Goodbye

Expert Answer

 solution;

package com.Adgs.methods;

import java.util.Scanner;

public class CheggString {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println(“enter the string”);

String sentence = scanner.nextLine();

System.out.println(“1. Convert to all uppercase letters”);
System.out.println(“2. Convert to all lowercase letters”);
System.out.println(“3. Display the length of the paragraph”);
System.out.println(“4. Select a substring from the paragraph”);
System.out
.println(“5. Let Random select a substring from the paragraph”);
System.out.println(“6. Exit”);
System.out.println(“enter your choice”);
int choice = scanner.nextInt();

switch (choice) {

case 1:
toUpper(sentence);
break;
case 2:
toLower(sentence);
break;
case 3:
findLength(sentence);
break;
case 4:
findSubString(sentence);
break;
case 5:
findRandomSubString(sentence);
break;
case 6:
System.exit(0);
default:
System.out.println(“please choose correct option “);
break;

}

}

private static void findRandomSubString(String sentence) {

int start = (int) (Math.random() * (sentence.length() – 1));
System.out.println(“the random starting point is ” + start);
Scanner scanner = new Scanner(System.in);
System.out.println(“enter the end point of the string”);
int end = scanner.nextInt();
System.out.println(sentence.substring(start, end));

}

private static void findSubString(String sentence) {
Scanner scanner = new Scanner(System.in);
System.out.println(“enter the index”);
int startIndex = scanner.nextInt();
int endIndex = scanner.nextInt();

String subString = sentence.substring(startIndex, endIndex);
System.out.println(“the string between ” + startIndex + “to” + endIndex
+ “:” + subString);

}

private static void findLength(String sentence) {
System.out.println(sentence.length());

}

private static void toLower(String sentence) {
System.out.println(sentence.toLowerCase());

}

private static void toUpper(String sentence) {

System.out.println(sentence.toUpperCase());
}

}

output

enter the string
: Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
1. Convert to all uppercase letters
2. Convert to all lowercase letters
3. Display the length of the paragraph
4. Select a substring from the paragraph
5. Let Random select a substring from the paragraph
6. Exit
enter your choice
1
: FOUR SCORE AND SEVEN YEARS AGO OUR FATHERS BROUGHT FORTH ON THIS CONTINENT, A NEW NATION, CONCEIVED IN LIBERTY, AND DEDICATED TO THE PROPOSITION THAT ALL MEN ARE CREATED EQUAL.

Still stressed from student homework?
Get quality assistance from academic writers!