Write a program that prompts the user for an odd positive integer, n, greater than 1, and then
prints the following hourglass figure which has a height of n text lines:
In this example: n = 9
********* (please refer to the attachment for the figure)
* *
* *
* *
*
* *
* *
* *
*********
Your program should check that the user enters a valid number for n and print an error message
if not. Make sure to use the right method. Your output should look exactly like the figure above:
symmetric and left-justified, with all stars * and spaces in the locations as shown. It should be
scaled appropriately for the given value of n. Please make sure that your program works for all
valid cases (e.g. check for n=3). It is recommended to break the entire job into small tasks to
handle each region of the figure. Make sure to use loops.
faisal.alawar 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
faisal.alawar 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Salem 5,248 Posting Sage
faisal.alawar 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
jonsca commented: Nice +1
Rahul.menon 0 Light Poster
prvnkmr449 -8 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.