• Post Reply Bookmark Topic Watch Topic
  • New Topic

Asterisks diamond program  RSS feed

 
Shal Lango
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write an application that prints a diamond shape diamond shape like the one below. The user should be asked to enter an odd integer  between  3 and 19 and this will determine the number of rows in the diamond. You may use output  statements  that print a single asterisk (*), a single space or a single new- line character . Maximize your use of repetition (with nested for statements ), and minimize the number of output  statements .



I attached the problem I am getting. The spacing of the asterisks is not right. Any help on fixing this is much appreciated.
Thank you.
snip.JPG
[Thumbnail for snip.JPG]
Error/output
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shalmika Elango wrote:The spacing of the asterisks is not right.


Well, that is a rather inadequate description of the problem. Actually, what you output is different from the required input, and you have a picture which you can look at. So start by looking at the picture and identify the differences. Next, find the part of your code which is responsible for each of the differences and fix that part to work correctly.

Yes, there's more than one difference and there's even more than one type of difference. So start at the top: your code produces two lines which are all blanks. Why is that?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Is this part of your college course, or is that a website testing your program?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!