10 Replies - 13548 Views - Last Post: 29 September 2010 - 08:12 AM Rate Topic: -----

#1 *sunshine*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-July 09

DIAMOND PATTERN PROGRAM ! !

Posted 09 July 2009 - 11:33 PM

guys, pls help me wid d diamond pattern ! ! ! ! !
I hav my project due next week . . . . . so HELP ! !



where integer arguement is n, where n=4

This post has been edited by *sunshine*: 09 July 2009 - 11:34 PM

Is This A Good Question/Topic? 0
  • +

Replies To: DIAMOND PATTERN PROGRAM ! !

#2 Tanira  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 102
  • Joined: 30-May 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 09 July 2009 - 11:37 PM

View Post*sunshine*, on 9 Jul, 2009 - 10:33 PM, said:

guys, pls help me wid d diamond pattern ! ! ! ! !
I hav my project due next week . . . . . so HELP ! !



where integer arguement is n, where n=4


We need more info to go off and also we need to see a reasonable amount of work on your behalf. Those are the rules.
Was This Post Helpful? 0
  • +
  • -

#3 ronaldjames  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 42
  • Joined: 29-June 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 12:11 AM

View Post*sunshine*, on 10 Jul, 2009 - 12:33 PM, said:

I hav my project due next week . . . . . so HELP ! !


D.I.C's policy is to help.

But we need to see that you has put some effort from your side.

Try for that program.
If any error occures paste that code here in this forum.
Somebody will come up with ideas.

Was This Post Helpful? 0
  • +
  • -

#4 blues90  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 20
  • Joined: 25-June 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 12:34 AM

LOL.. :D ..U didnt wrote any code for your assignment?? Try to do it by your own, and then ask D.I.C.. Must be helped by programmer at here.. B)
Was This Post Helpful? 0
  • +
  • -

#5 *sunshine*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-July 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 05:44 AM

this is what I wrote . . . . please tell me what's wrong in this :



class diamond
{
public static void main
{
int i , j , k, n = 24;

k=(n%2==0)? n-1:n;

for( i = 0 ; i < n/2 ; i++ )
{
for( j = 0 ; j < k / 2 - i ; j++ )
System.out.print(" ");

for ( j = 0 ; j < i * 2 + 1 ; j++ )
System.out.print("*");

System.out.println();
}

if( n % 2 != 0)
{
for( i = 0 ; i < n ; i++ )
System.out.print("*");

System.out.println();
}

for( i = n/2-1 ; i >= 0 ; i-- )
{
for( j = 0 ; j < k/2 - i ; j++ )
System.out.print(" ");

for( j = 0 ; j < i*2+1 ; j++ )
System.out.print("*");

System.out.println();
}
}
}
Was This Post Helpful? 0
  • +
  • -

#6 arsh_aarsh  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 36
  • Joined: 13-October 08

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 06:07 AM

View Post*sunshine*, on 10 Jul, 2009 - 04:44 AM, said:

this is what I wrote . . . . please tell me what's wrong in this :



class diamond
{
public static void main
{
int i , j , k, n = 24;

k=(n%2==0)? n-1:n;

for( i = 0 ; i < n/2 ; i++ )
{
for( j = 0 ; j < k / 2 - i ; j++ )
System.out.print(" ");

for ( j = 0 ; j < i * 2 + 1 ; j++ )
System.out.print("*");

System.out.println();
}

if( n % 2 != 0)
{
for( i = 0 ; i < n ; i++ )
System.out.print("*");

System.out.println();
}

for( i = n/2-1 ; i >= 0 ; i-- )
{
for( j = 0 ; j < k/2 - i ; j++ )
System.out.print(" ");

for( j = 0 ; j < i*2+1 ; j++ )
System.out.print("*");

System.out.println();
}
}
}


Can you please also post its output?
Was This Post Helpful? 0
  • +
  • -

#7 *sunshine*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-July 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 06:26 AM

I couldnt get d output . . . . d program wouldnt compile only
Was This Post Helpful? 0
  • +
  • -

#8 jpav  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 29
  • Joined: 08-July 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 10 July 2009 - 08:22 AM

View Post*sunshine*, on 10 Jul, 2009 - 04:44 AM, said:

this is what I wrote . . . . please tell me what's wrong in this :

To begin with, you have a fairly basic syntax problem to fix before you can get anywhere. "main" is a method and therefore must be followed by parentheses. It must also be defined to accept a single array of Strings as its only parameter.
Was This Post Helpful? 0
  • +
  • -

#9 Guest_Akul*


Reputation:

Re: DIAMOND PATTERN PROGRAM ! !

Posted 28 March 2010 - 12:04 AM

no () put after void main
the output is
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*********************
***********************
***********************
*********************
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
Was This Post Helpful? 0

#10 Guest_African_warrior*


Reputation:

Re: DIAMOND PATTERN PROGRAM ! !

Posted 29 September 2010 - 07:38 AM

The programs works however he forgot to put (String []args)
i know this answer is too late but for other who might need it later :)
-----------------------------------------------------------------------
class diamond 
{
public static void main(String []args) 
{
int i , j , k, n = 24; 

k=(n%2==0)? n-1:n; 

for( i = 0 ; i < n/2 ; i++ ) 
{
for( j = 0 ; j < k / 2 - i ; j++ ) 
System.out.print(" ");

for ( j = 0 ; j < i * 2 + 1 ; j++ ) 
System.out.print("*");

System.out.println(); 
}

if( n % 2 != 0)
{
for( i = 0 ; i < n ; i++ ) 
System.out.print("*");

System.out.println(); 
}

for( i = n/2-1 ; i >= 0 ; i-- ) 
{
for( j = 0 ; j < k/2 - i ; j++ ) 
System.out.print(" ");

for( j = 0 ; j < i*2+1 ; j++ ) 
System.out.print("*");

System.out.println(); 
}
}
}

This post has been edited by JackOfAllTrades: 29 September 2010 - 07:39 AM
Reason for edit:: Added code tags

Was This Post Helpful? 0

#11 Luckless  Icon User is offline

  • </luck>
  • member icon

Reputation: 292
  • View blog
  • Posts: 1,146
  • Joined: 31-August 09

Re: DIAMOND PATTERN PROGRAM ! !

Posted 29 September 2010 - 08:12 AM

Please don't post working solutions, as others might have the same assignment. While you guys found the problem, it is up to the OP to fix it. We are here to guide and prod in the right direction, but we are not supposed to give out something they can copy, paste, and turn in. Thanks for your time.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1