hi im having problem on how to make the output of my programme like this:
if you enter a number: (EVEN)

     *
    **
   ***
 *****        

If you enter a number:(ODD)

 *****
  ****
   ***
    **
     *

im always having an output of:
(EVEN)

*
**
***
****

(ODD)

*****
****
***
**
*

I hope somebody will help me:
here is my code:

import java.io.*;


public class del
{
    public static void main(String[]args)throws IOException
{


        BufferedReader IN = new BufferedReader(new InputStreamReader(System.in));
        int a, c, d; 
        String b, e, f;

    do{
            System.out.println("Enter name:");
    f = IN.readLine();
            System.out.println("Enter a number:");
                b = IN.readLine();
                d = Integer.parseInt(b);

        if(d%2==0)
        {

            for(a=d;a>=0;a--)
            {


                for(c=a;c<d;c++)
                {
                    System.out.print(f);

                }

                    System.out.println("  ");
            }

        }
        else
        {

            for(a=0;a<=d;a+=1)
            {

                for(c=a;c<d;c++)
                {
                    System.out.print(f);
                }

                    System.out.println("  ");
            }

        }

        System.out.print("Try Again?:");

        e = IN.readLine();

        }while(e.charAt(0)=='y'||e.charAt(0)=='Y');




}
}

Recommended Answers

All 13 Replies

Welcome sympatiko.

Use BB code tags. Your source code must be surrounded with bb code tags. Read How to wrap up source code with bb code tags?

You are near to the solution. Keep it up.

im a newbie in programming,,i cant understand those kind of coding,,can you please solve my problem if you know?

Input a number and if it is odd then make it even.

im a newbie in programming,,i cant understand those kind of coding,,can you please solve my problem if you know?

The request to use code tags has nothing to do with programming ability; code tags are required because all spacing/formatting is stripped out when you do not use them. Your code is unreadable without them, and more important, your asterisk patterns are unreadable because all spaces are stripped without code tags.

[code]
paste code or pattern here
[/code]

Note the difference (with code tags):

[code]
*
*
*
*
[/code]

Without code tags:

*
*
*
*

Please repost using code tags, as explained above. Again, do this to retain spacing. Thanks.

hi im having problem on how to make the output of my programme like this:
if you enter a number: (EVEN)

     *
    **
   ***
 *****        

If you enter a number:(ODD)

 *****
  ****
   ***
    **
     *

im always having an output of:

(EVEN)
*
**
***
****

(ODD)
*****
****
***
**
*

I hope somebody will haelp me:
here is my code:

import java.io.*;


public class del
{
    public static void main(String[]args)throws IOException
{


        BufferedReader IN = new BufferedReader(new InputStreamReader(System.in));
        int a, c, d; 
        String b, e, f;

    do{
            System.out.println("Enter name:");
    f = IN.readLine();
            System.out.println("Enter a number:");
                b = IN.readLine();
                d = Integer.parseInt(b);

        if(d%2==0)
        {

            for(a=d;a>=0;a--)
            {


                for(c=a;c<d;c++)
                {
                    System.out.print(f);

                }

                    System.out.println("  ");
            }

        }
        else
        {

            for(a=0;a<=d;a+=1)
            {

                for(c=a;c<d;c++)
                {
                    System.out.print(f);
                }

                    System.out.println("  ");
            }

        }

        System.out.print("Try Again?:");

        e = IN.readLine();

        }while(e.charAt(0)=='y'||e.charAt(0)=='Y');




}
}

end quote.

i mean the real output put must be
if even:

    *
  ****
******

if odd:

******
 ****
    *

so now,,give me the code,,how to make that

i mean the real output put must be
if even:
*
****
******

if odd:
******
****
*

so now,,give me the code,,how to make that

i mean half diamond,,not a right triangle

i want a quick solution man

commented: Rude, demanding, no effort, no code tags. -4
import java.io.*;


public class p
{
public static void main(String[]args)throws IOException
{
 
   BufferedReader IN = new BufferedReader(new 

InputStreamReader(System.in));
   int a, c, d,cnt; 
   String b, e, f;

   do{
       System.out.println("Enter name:");
       f = IN.readLine();
       System.out.println("Enter a number:");
       b = IN.readLine();
       d = Integer.parseInt(b);
       if(d%2==0)
          {
             for(a=1;a<=d;a++)
               {
                 if(a==1)
                  cnt=1;
                 else
                  cnt=a*2;
                 for(c=1;c<=cnt;c++)
                    {
                      System.out.print(f);
                    }
               System.out.println(" ");
           }
       }
    else
        {
         for(a=d;a>=1;a--)
             {
                 if(a==1)
                  cnt=1;
                 else
                  cnt=a*2;
               for(c=1;c<=cnt;c++)
                 {
                   System.out.print(f);
                 }
            System.out.println(" ");
          }
   }
   System.out.print("Try Again?:");
   e = IN.readLine();
   }while(e.charAt(0)=='y'||e.charAt(0)=='Y');
  }
}

i want a quick solution man

I want a million dollars. The answer is no. We don't give out free code to people who make absolutely no effort.

i want a quick solution man

Then you'd better get crackin'!

I want a million dollars. The answer is no. We don't give out free code to people who make absolutely no effort.

what effor1 do you want for me??,,im 1 week trying for two projects,,this java is killing me

what effor1 do you want for me??,,im 1 week trying for two projects,,this java is killing me

Read my post 5 again. I told you exactly why you needed to use code tags around your diamond pattern and exactly how to do it. No one can make an sense of your diamond pattern if you don't use code tags because ALL SPACING IS STRIPPED OUT OF A POST THAT DOES NOT USE CODE TAGS!

Any pattern and any code needs to be in code tags for this reason. You refused to accommodate or even acknowledge this very simple request, plus you have a sense of entitlement that is very offputting. Hence your lack of effort. If you had used code tags, sentences like this would be unnecessary:

i mean half diamond,,not a right triangle

because the spacing would not be stripped out.

so now,,give me the code,,how to make that

We don't just give out the code if we can help it. We give hints, we try to help. We don't do the whole thing for you and post the finished product. And have you ever heard of the word "please"?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.