Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,517 members, 7,958,569 topics. Date: Wednesday, 25 September 2024 at 05:27 PM |
Nairaland Forum / Science/Technology / Programming / How To Print Diamond With A Frame Using Java (1290 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" // for the top cover System.out.print("+" for(int i = 0; i<=(size*2); i++){ System.out.print("-" } System.out.println("+" // for the side int count = 0; for(int i = 1; i<=(size*2)-1; i++){ System.out.print("|" for(int j = 0; j<=(size*2); j++){ System.out.print(" " } System.out.println("|" } // For the bottom System.out.print("+" for(int i = 0; i<=(size*2); i++){ System.out.print("-" } System.out.println("+" } }
|
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:The variable size was declared in the other part of my code. Well I latter figured exactly what I needed. Thanks |
(1) (Reply)
Sketchware Help! / Introduction / How Much Do You Earn As A Programmer/developer
(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 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |