Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
Red Hat Certified System Administrator (RHCSA) - RHEL 10
Sanjeewani95
Updated:
Friday at 7:43 PM
NURSING , CAREGIVER , HOTEL & BEAUTY COURSES
IVA Para Medical Campus
Updated:
Thursday at 9:24 AM
Handmade Character Soft Toys Peppa Pig Family
anil1961
Updated:
Wednesday at 9:58 PM
Ad icon
Video Content Creator
pramukag
Updated:
Jun 28, 2026
Ad icon
QA Engineer Intern
pramukag
Updated:
Jun 28, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Thread for Programming and Realeted Topics
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="rclakmal" data-source="post: 5587246" data-attributes="member: 98858"><p>i saw a question on "YAHOO ANSWERS" and and here is my solution for all of u !!!!!!</p><p></p><p>Question was ---</p><p>[code]</p><p>[B][SIZE=2]How to do this java programme?[/SIZE][/B]</p><p></p><p> [SIZE=2]Q3. Write a program to draw a diamond sign in to the screen with different heights entered by the user. See following example. </p><p></p><p>Enter the height of the diagonal: 7 </p><p> *</p><p> * *</p><p> * * *</p><p> * * * *</p><p> * * *</p><p> * *</p><p> *</p><p>[URL]http://answers.yahoo.com/question/index?qid=20090925215708AAkjRKl[/URL]</p><p>[/code]</p><p></p><p></p><p>and here is my answer [code]</p><p>package diamond;</p><p>import java.util.Scanner;</p><p></p><p>/**</p><p> *</p><p> * @author lakmal</p><p> */</p><p>class Diamond {</p><p></p><p> /**</p><p> * @param args the command line arguments</p><p> */</p><p> static int height;</p><p> static char state;</p><p> Diamond(int height){</p><p> for (int i=1;i<=height;i++){</p><p> if (i<=(height/2)){</p><p> for (int j=1;j<=i;j++){</p><p> System.out.print(" *");</p><p> </p><p> }</p><p> }</p><p> else{</p><p> for(int j=1;j<=(height+1-i);j++){</p><p> System.out.print(" *");</p><p> </p><p></p><p> }</p><p> }</p><p> System.out.println();</p><p> }</p><p> }</p><p></p><p> public static void main(String[] args) {</p><p> // TODO code application logic here</p><p> Scanner input=new Scanner(System.in);</p><p> do{</p><p></p><p> do{</p><p> System.out.println("Enter your height");</p><p> height=input.nextInt();</p><p> Diamond d1=new Diamond(height);</p><p> } while(height%2!=0);</p><p> System.out.println("Enter a odd number!!");</p><p> System.out.println("Do you want to continue?(y/n)");</p><p> state=input.next().charAt(0);</p><p></p><p></p><p></p><p> } while(state=='y');</p><p></p><p> }</p><p>}</p><p></p><p>[/code]</p><p></p><p>Happy coding !!!!!</p><p>[/SIZE]</p></blockquote><p></p>
[QUOTE="rclakmal, post: 5587246, member: 98858"] i saw a question on "YAHOO ANSWERS" and and here is my solution for all of u !!!!!! Question was --- [code] [B][SIZE=2]How to do this java programme?[/SIZE][/B] [SIZE=2]Q3. Write a program to draw a diamond sign in to the screen with different heights entered by the user. See following example. Enter the height of the diagonal: 7 * * * * * * * * * * * * * * * * [URL]http://answers.yahoo.com/question/index?qid=20090925215708AAkjRKl[/URL] [/code] and here is my answer [code] package diamond; import java.util.Scanner; /** * * @author lakmal */ class Diamond { /** * @param args the command line arguments */ static int height; static char state; Diamond(int height){ for (int i=1;i<=height;i++){ if (i<=(height/2)){ for (int j=1;j<=i;j++){ System.out.print(" *"); } } else{ for(int j=1;j<=(height+1-i);j++){ System.out.print(" *"); } } System.out.println(); } } public static void main(String[] args) { // TODO code application logic here Scanner input=new Scanner(System.in); do{ do{ System.out.println("Enter your height"); height=input.nextInt(); Diamond d1=new Diamond(height); } while(height%2!=0); System.out.println("Enter a odd number!!"); System.out.println("Do you want to continue?(y/n)"); state=input.next().charAt(0); } while(state=='y'); } } [/code] Happy coding !!!!! [/SIZE] [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom