HollowPlusSign

Write a program that prints a hollow plus sign. Ask the user what size plus sign he/she wants and print it out. Name your program Unit9Assignment.Example 1:This program prints a hollow plus sign.
What size plus sign would you like? 6Here is your plus sign of size 6:* *
* *
* * * * * *
* * * * * *
* *
* *
Example 2:This program prints a hollow plus sign.
What size plus sign would you like? 9Here is your plus sign of size 9:* * *
* *
* *
* * * * * * * *
* *
* * * * * * * *
* *
* *
* * *
Example 3:This program prints a hollow plus sign.
What size plus sign would you like? 15Here is your plus sign of size 15:* * * * *
* *
* *
* *
* *
* * * * * * * * * * * *
* *
* *
* *
* * * * * * * * * * * *
* *
* *
* *
* *
* * * * *
Example 4:This program prints a hollow plus sign.
What size plus sign would you like? 0
The size must be positive and divisible by 3.
What size plus sign would you like? 1
The size must be positive and divisible by 3.
What size plus sign would you like? -3
The size must be positive and divisible by 3.
What size plus sign would you like? 3Here is your plus sign of size 3:*
* * *
*
Hint #1: the mod operator (%) can be used to determine if a number is ***** by 3.Hint #2: there is a lot of duplicate work in printing the various parts of the plus sign. Writing methods will save you a lot of coding and make your program simpler.

×
New Download