
Explanation of Solution
Program code:
Text.java
//import the required packages
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
//create a class Text
public class Text
{
//define main() method
public static void main(String[] args)
{
//create the object of Scanner class
Scanner scan = new Scanner(System.in);
//prompt the user to enter the strings
System.out.println("Enter the String to print in box");
//scan for the strings
String text=scan.nextLine();
//print a vertical line
System.out.print("|");
//iterate a for loop up to i<text.length()
for(int i=-2;i<text.length()+2;i++)
{
//print horizontal lines
System.out.print("-");
}
//print vertical line
System...

Want to see the full answer?
Check out a sample textbook solution
Chapter 6 Solutions
MyProgrammingLab with Pearson eText -- Access Code Card -- for Building Java Programs
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





