60 435
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #33425 in Java | JSP | JSF for Jimbo

Question #33425
Write a program NamePrinter that displays your name inside a box on the console screen, like this:
+----+
|Dave|
+----+
Do your best to approximate lines with characters, such as |, -, and +.
Expert's answer
import java.util.Scanner;


public class NamePrinter {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter name: ");//input name
String name =input.nextLine();//read name
//show result
System.out.print("+");
for(int i=0;i<name.length();i++){
System.out.print("-");
}
System.out.println("+");
System.out.print("|");
System.out.print(name);
System.out.println("|");
System.out.print("+");
for(int i=0;i<name.length();i++){
System.out.print("-");
}
System.out.print("+");

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
23.07.13, 15:03

<div>You're welcome. We are glad to be helpful.</div><div>If you really liked our service please press like-button beside answer field. Thank you!</div><div>
</div>

Jimbo
22.07.13, 19:17

Awesome. Thank you

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions