0

hello i am stuk on this piece of work which i have no understaning at all!!! this is the question could someone please show me or give me gudlines in how to do it!!!

Write a Java application that asks a user for their name and displays it in a ‘box’ similar to that you implemented in week 1, exercise 1. For this application, you use a for loop to repeated printing * and space characters to result in the boundaries and padding, respectively. Below is what your application should produce.

Please enter your name> king 786

/********\
| |
| king 786 |
| |
\********/

The number of characters (* or space) is determined by the length of the name entered (hint: use String length method). Remember that you have to add 2 to this length in order to take into account the space either side of the name.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by deathwishgenius
0

well, before you get torched I'll help...

but you know I'm not just going to give you the answer... ;)

first, condense what you know like this...

From: "Write a Java application that asks a user for their name and displays it in a ‘box’ similar to that you implemented in week 1, exercise 1. For this application, you use a for loop to repeated printing * and space characters to result in the boundaries and padding, respectively. Below is what your application should produce.

Please enter your name> king 786

/********\
| |
| king 786 |
| |
\********/

The number of characters (* or space) is determined by the length of the name entered (hint: use String length method). Remember that you have to add 2 to this length in order to take into account the space either side of the name."

to something like:

"
prompt userName,
display in ‘box’
use for loop with println
///Example:
Please enter your name> king 786
should return:
/********\
| |
| king 786 |
| |
\********/
(hint: use String length method). ...for spacing add 2 for either side
"

then do it...


Scanner keyboard = new scanner(System.in);

...

have fun

0

declare your variables then throw this in main: Don't forget I pseudocoded it...but this is downright simple to fix.

//prompt userName

println("Please enter your name> ");
nextLine();

//display in ‘box’

//first line
print("/")
for (count = 1; count <= name.length(); count++)
print("*")
println("\\");

//second line
println("| |");

//third line
println("| " + name + " |");

//fourth line
println("| |");

//fifth line
print("\\");
for (count = 1; count <= name.length(); count++)
print("*");
println("/");

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.