Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume we have already defined a variable of type String called name with the following line of code: String name = ???; // 'name' can

Assume we have already defined a variable of type String called name with the following line of code:

String name = "???"; // 'name' can have any String value

TASK: Print a welcome message "Hello, name! Welcome to CS 7! :)" surrounded by a box of asterisks (*) with spaces separating the box and your text.

EXAMPLE: If name is "Newman", you would print the following:

************************************** * * * Hello, Newman! Welcome to CS 7! :) * * * **************************************

EXAMPLE: If name was "Jerry", you would print the following:

************************************* * * * Hello, Jerry! Welcome to CS 7! :) * * * *************************************

NOTE: Notice how the length of name affects the length of the message, which in turn affects the number of surrounding asterisks and spaces.

NOTE: You do not need to create a class or main method, and you do not need to create the variable name. We have done all of that behind the scenes.

HINT: Try to re-use your code from the previous two problems! Figure out how many asterisks go on the 1st/5th rows, and figure out how many spaces go on the 2nd/4th rows.

Sample Input 1:

Frodo

Sample Output 1:

************************************* * * * Hello, Frodo! Welcome to CS 7! :) * * * *************************************

Sample Input 2:

Sam

Sample Output 2:

*********************************** * * * Hello, Sam! Welcome to CS 7! :) * * * ***********************************

PLEASE USE JAVA

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

More Books

Students also viewed these Databases questions

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago