Question: Assume we have defined a variable variable of type int called numSpaces with the following line of code: int numSpaces = ???; // numAsterisks can

Assume we have defined a variable variable of type int called numSpaces with the following line of code:

int numSpaces = ???; // numAsterisks can have any value

TASK: Print out two asterisks(i.e. the character '*'), with numSpaces empty spaces in between. In other words:

  1. Print a single asterisk
  2. Print an empty space exactly numSpaces times
  3. Print a single asterisk

EXAMPLE: If numSpaces is 5, you would print the following:

* *

NOTE: You do not need to create a class or a main method. We have done that behind the scenes.

Sample Input 1:

5

Sample Output 1:

* *

Sample Input 2:

8

Sample Output 2:

* *

PLEASE ANSWER IN JAVA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!