Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,775,286 members, 6,611,076 topics. Date: Wednesday, 01 December 2021 at 06:48 AM

How To Print Diamond With A Frame Using Java - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How To Print Diamond With A Frame Using Java (1008 Views)

Who Can Solve This Problem Using Java / Programmers In The House, Kindly Help Me Table Like This....using Java Awt / How To Check Your Account Balance And Make Deposit Using Java (2) (3) (4)

(1) (Reply)

How To Print Diamond With A Frame Using Java by JAtoms: 9:12pm On Sep 29, 2018
Hello I am still a learner, I am faced with writing a java code that prints a diamond with a frame enclosing the diamond. I have tried making the frame, but I am having challenge forming the diamond. I have attached a picture sample of how the diamond should look like

Here is a sample of my code:

System.out.print("\n"wink;

// for the top cover
System.out.print("+"wink;
for(int i = 0; i<=(size*2); i++){
System.out.print("-"wink;
}
System.out.println("+"wink;


// for the side
int count = 0;
for(int i = 1; i<=(size*2)-1; i++){
System.out.print("|"wink;
for(int j = 0; j<=(size*2); j++){
System.out.print(" "wink;
}

System.out.println("|"wink;

}


// For the bottom
System.out.print("+"wink;
for(int i = 0; i<=(size*2); i++){
System.out.print("-"wink;
}
System.out.println("+"wink;
}

}

Re: How To Print Diamond With A Frame Using Java by sparkle6(m): 7:42pm On Sep 30, 2018
Awesome! You my friend is good. But i still dnt get how a diamond is useful in real programming. Unless its just to hone up ur problem solving skills but kudos. Also where did you declare variable 'size'. You use Javafx? holla me if u do.
Re: How To Print Diamond With A Frame Using Java by JAtoms: 8:54pm On Oct 04, 2018
sparkle6:
Awesome! You my friend is good. But i still dnt get how a diamond is useful in real programming. Unless its just to hone up ur problem solving skills but kudos. Also where did you declare variable 'size'. You use Javafx? holla me if u do.
The variable size was declared in the other part of my code. Well I latter figured exactly what I needed. Thanks

(1) (Reply)

I Need Tech Skills / I Need An App For My Website Integrated With Admob / I Want A Forex Tutor.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2021 Oluwaseun Osewa. All rights reserved. See How To Advertise. 31
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.