How to do this?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amanda

    How to do this?

    Write a program that will allow user to choose to display traingles
    and diamonds composed of asterisks ina lopping condition?

    a. Display the traingles one below the other, like this:
    *
    **
    ***
    ****
    *****

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

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

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

    b. Display the traingles side by side:

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

    c. Display diamond of the appropriate size (prompt the user to eneter
    an odd integer and then use it to loop); if user enter 5:

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

    NOTE: I will use switch to allow selction; to make trangles and
    diamonds, I want to use arrays in
    the loop. If possible, I would like to make one or two methods of
    making traingles (of different orienatation) and then call them to
    display desired pattern. Any guide?

  • Amanda

    #2
    Re: How to do this?

    In fact, here is the required instruction:

    Use for loops to generate the appterns. All asterisks (*) should be
    printed by a single statement of the form Console.Write( '*' ); Use a
    statement of Console.WriteLi ne( ) to position to the next line; Use a
    statement of Console.WriteLi ne( "" ) to display a space.

    another option is e whoch ich exit the program; Any thing other than
    a,b,c,e, will prompt error messagebox. I can do all that.

    I just need logic how to go about the pattern.




    Amanda wrote:
    Write a program that will allow user to choose to display traingles
    and diamonds composed of asterisks ina lopping condition?
    >
    a. Display the traingles one below the other, like this:
    *
    **
    ***
    ****
    *****
    >
    *****
    ****
    ***
    **
    *
    >
    *****
    ****
    ***
    **
    *
    >
    *
    **
    ***
    ****
    *****
    >
    b. Display the traingles side by side:
    >
    * ***** ***** *
    ** **** **** **
    *** *** *** ***
    **** ** ** ****
    ***** * * *****
    >
    c. Display diamond of the appropriate size (prompt the user to eneter
    an odd integer and then use it to loop); if user enter 5:
    >
    *
    ***
    *****
    *******
    *********
    *******
    *****
    ***
    *
    >
    NOTE: I will use switch to allow selction; to make trangles and
    diamonds, I want to use arrays in
    the loop. If possible, I would like to make one or two methods of
    making traingles (of different orienatation) and then call them to
    display desired pattern. Any guide?

    Comment

    • Peter Duniho

      #3
      Re: How to do this?

      "Amanda" <amanda772008@y ahoo.comwrote in message
      news:1160285715 .712717.322870@ m7g2000cwm.goog legroups.com...
      In fact, here is the required instruction:
      >
      Use for loops to generate the appterns. All asterisks (*) should be
      printed by a single statement of the form Console.Write( '*' ); Use a
      statement of Console.WriteLi ne( ) to position to the next line; Use a
      statement of Console.WriteLi ne( "" ) to display a space.
      >
      another option is e whoch ich exit the program; Any thing other than
      a,b,c,e, will prompt error messagebox. I can do all that.
      >
      I just need logic how to go about the pattern.
      Geez...haven't the teachers gotten new ideas for homework assignments? I
      remember being assigned something like this almost thirty years ago.

      Anyway, I think you'll get more out of the help if you go directly to your
      teacher or teaching assistant. They can not only provide insight into the
      implementation, they can explain better than someone here can the missing
      pieces that may be preventing you from seeing the solution in the first
      place.

      They are there to help...you should take advantage of that. (And if they
      aren't helping, let their supervisors know!)

      Pete


      Comment

      • Amanda

        #4
        Re: How to do this?

        This is online class. Difficult to ask instructor without saying' How
        to do this?":)


        Peter Duniho wrote:
        "Amanda" <amanda772008@y ahoo.comwrote in message
        news:1160285715 .712717.322870@ m7g2000cwm.goog legroups.com...
        In fact, here is the required instruction:

        Use for loops to generate the appterns. All asterisks (*) should be
        printed by a single statement of the form Console.Write( '*' ); Use a
        statement of Console.WriteLi ne( ) to position to the next line; Use a
        statement of Console.WriteLi ne( "" ) to display a space.

        another option is e whoch ich exit the program; Any thing other than
        a,b,c,e, will prompt error messagebox. I can do all that.

        I just need logic how to go about the pattern.
        >
        Geez...haven't the teachers gotten new ideas for homework assignments? I
        remember being assigned something like this almost thirty years ago.
        >
        Anyway, I think you'll get more out of the help if you go directly to your
        teacher or teaching assistant. They can not only provide insight into the
        implementation, they can explain better than someone here can the missing
        pieces that may be preventing you from seeing the solution in the first
        place.
        >
        They are there to help...you should take advantage of that. (And if they
        aren't helping, let their supervisors know!)
        >
        Pete

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: How to do this?

          Amanda <amanda772008@y ahoo.comwrote:
          In fact, here is the required instruction:
          >
          Use for loops to generate the appterns. All asterisks (*) should be
          printed by a single statement of the form Console.Write( '*' ); Use a
          statement of Console.WriteLi ne( ) to position to the next line; Use a
          statement of Console.WriteLi ne( "" ) to display a space.
          >
          another option is e whoch ich exit the program; Any thing other than
          a,b,c,e, will prompt error messagebox. I can do all that.
          >
          I just need logic how to go about the pattern.
          I suspect (and hope) that no-one on the group will do your homework for
          you. However, if you say exactly which part of the pattern logic you're
          having problems with, how far you've got with it, and what code you've
          already got, we may be able to help you.

          --
          Jon Skeet - <skeet@pobox.co m>
          http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
          If replying to the group, please do not mail me too

          Comment

          • Peter Duniho

            #6
            Re: How to do this?

            "Amanda" <amanda772008@y ahoo.comwrote in message
            news:1160287175 .214951.301700@ k70g2000cwa.goo glegroups.com.. .
            This is online class. Difficult to ask instructor without saying' How
            to do this?":)
            Sorry...I didn't realize we were the ones teaching the class. ;)


            Comment

            • Cor Ligthert [MVP]

              #7
              Re: How to do this?

              Jon,

              It is seldom that we have the same thought, it was the first that came in my
              mind.

              Cor

              "Jon Skeet [C# MVP]" <skeet@pobox.co mschreef in bericht
              news:MPG.1f92a6 2bc04807a98d523 @msnews.microso ft.com...
              Amanda <amanda772008@y ahoo.comwrote:
              >In fact, here is the required instruction:
              >>
              >Use for loops to generate the appterns. All asterisks (*) should be
              >printed by a single statement of the form Console.Write( '*' ); Use a
              >statement of Console.WriteLi ne( ) to position to the next line; Use a
              >statement of Console.WriteLi ne( "" ) to display a space.
              >>
              >another option is e whoch ich exit the program; Any thing other than
              >a,b,c,e, will prompt error messagebox. I can do all that.
              >>
              >I just need logic how to go about the pattern.
              >
              I suspect (and hope) that no-one on the group will do your homework for
              you. However, if you say exactly which part of the pattern logic you're
              having problems with, how far you've got with it, and what code you've
              already got, we may be able to help you.
              >
              --
              Jon Skeet - <skeet@pobox.co m>
              http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
              If replying to the group, please do not mail me too

              Comment

              • Greg Young

                #8
                Re: How to do this?

                think about this as a looping problem .. notice that a triangle is ..

                * 1
                ** 2
                *** 3
                etc ...

                this little bit of knowledge and some reading up on how for loops work
                should get you in the right direction.

                Cheers,

                Greg

                "Amanda" <amanda772008@y ahoo.comwrote in message
                news:1160287175 .214951.301700@ k70g2000cwa.goo glegroups.com.. .
                This is online class. Difficult to ask instructor without saying' How
                to do this?":)
                >
                >
                Peter Duniho wrote:
                >"Amanda" <amanda772008@y ahoo.comwrote in message
                >news:116028571 5.712717.322870 @m7g2000cwm.goo glegroups.com.. .
                In fact, here is the required instruction:
                >
                Use for loops to generate the appterns. All asterisks (*) should be
                printed by a single statement of the form Console.Write( '*' ); Use a
                statement of Console.WriteLi ne( ) to position to the next line; Use a
                statement of Console.WriteLi ne( "" ) to display a space.
                >
                another option is e whoch ich exit the program; Any thing other than
                a,b,c,e, will prompt error messagebox. I can do all that.
                >
                I just need logic how to go about the pattern.
                >>
                >Geez...haven 't the teachers gotten new ideas for homework assignments? I
                >remember being assigned something like this almost thirty years ago.
                >>
                >Anyway, I think you'll get more out of the help if you go directly to
                >your
                >teacher or teaching assistant. They can not only provide insight into
                >the
                >implementation , they can explain better than someone here can the missing
                >pieces that may be preventing you from seeing the solution in the first
                >place.
                >>
                >They are there to help...you should take advantage of that. (And if they
                >aren't helping, let their supervisors know!)
                >>
                >Pete
                >

                Comment

                • Amanda

                  #9
                  Re: How to do this?


                  Greg Young wrote:
                  think about this as a looping problem .. notice that a triangle is ..
                  >
                  * 1
                  ** 2
                  *** 3
                  etc ...
                  >
                  this little bit of knowledge and some reading up on how for loops work
                  should get you in the right direction.
                  >
                  Cheers,
                  I got the traingles showing below one another by callign thefollowing
                  functions:

                  public static void Triangle1()
                  { for (int i = 0, j = 0; i < 8; i++)
                  { for (int c = 0; c <= j; c++)
                  Console.Write(" *");
                  Console.WriteLi ne();
                  j++;
                  }
                  } // end Triangle1( )

                  public static void Triangle2()
                  { for (int i = 8, j = 1; i 0; i--)
                  {
                  for (int c = 8; c >= j; c--)
                  Console.Write(" *");
                  Console.WriteLi ne();
                  j++;
                  }
                  }


                  Now, I am trying the triagles showing side by side like this - I am
                  trying to show the first two):

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

                  >
                  Greg
                  >
                  "Amanda" <amanda772008@y ahoo.comwrote in message
                  news:1160287175 .214951.301700@ k70g2000cwa.goo glegroups.com.. .
                  This is online class. Difficult to ask instructor without saying' How
                  to do this?":)


                  Peter Duniho wrote:
                  "Amanda" <amanda772008@y ahoo.comwrote in message
                  news:1160285715 .712717.322870@ m7g2000cwm.goog legroups.com...
                  In fact, here is the required instruction:

                  Use for loops to generate the appterns. All asterisks (*) should be
                  printed by a single statement of the form Console.Write( '*' ); Use a
                  statement of Console.WriteLi ne( ) to position to the next line; Use a
                  statement of Console.WriteLi ne( "" ) to display a space.

                  another option is e whoch ich exit the program; Any thing other than
                  a,b,c,e, will prompt error messagebox. I can do all that.

                  I just need logic how to go about the pattern.
                  >
                  Geez...haven't the teachers gotten new ideas for homework assignments? I
                  remember being assigned something like this almost thirty years ago.
                  >
                  Anyway, I think you'll get more out of the help if you go directly to
                  your
                  teacher or teaching assistant. They can not only provide insight into
                  the
                  implementation, they can explain better than someone here can the missing
                  pieces that may be preventing you from seeing the solution in the first
                  place.
                  >
                  They are there to help...you should take advantage of that. (And if they
                  aren't helping, let their supervisors know!)
                  >
                  Pete

                  Comment

                  • Amanda

                    #10
                    Re: How to do this?


                    Jon wrote:
                    Amanda <amanda772008@y ahoo.comwrote:
                    In fact, here is the required instruction:

                    Use for loops to generate the appterns. All asterisks (*) should be
                    printed by a single statement of the form Console.Write( '*' ); Use a
                    statement of Console.WriteLi ne( ) to position to the next line; Use a
                    statement of Console.WriteLi ne( "" ) to display a space.

                    another option is e whoch ich exit the program; Any thing other than
                    a,b,c,e, will prompt error messagebox. I can do all that.

                    I just need logic how to go about the pattern.
                    >
                    I suspect (and hope) that no-one on the group will do your homework for
                    you.
                    I didn't expect anything else but this. I am just surprised that there
                    are not more people saying it. The funny thing about people is that
                    they are either blinded by their ego, and act arrogant or they judge
                    others with their standard.

                    I am auditing the class and I am trying to learn C# and in the process,
                    are doing these assignments. Note that in my initial post, I
                    said,"Suggest me with logic". I didn't say write code for me but then
                    your ego has blinded you such that you couldn't even read properly.


                    >However, if you say exactly which part of the pattern logic you're
                    having problems with, how far you've got with it, and what code you've
                    already got, we may be able to help you.
                    >
                    --
                    Jon Skeet - <skeet@pobox.co m>
                    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                    If replying to the group, please do not mail me too

                    Comment

                    • Amanda

                      #11
                      Re: How to do this?


                      Cor Ligthert [MVP] wrote:
                      Jon,
                      >
                      It is seldom that we have the same thought, it was the first that came in my
                      mind.
                      >
                      Cor
                      What's applied to Jon applies to you too. You can't read properly
                      either.

                      >
                      "Jon Skeet [C# MVP]" <skeet@pobox.co mschreef in bericht
                      news:MPG.1f92a6 2bc04807a98d523 @msnews.microso ft.com...
                      Amanda <amanda772008@y ahoo.comwrote:
                      In fact, here is the required instruction:
                      >
                      Use for loops to generate the appterns. All asterisks (*) should be
                      printed by a single statement of the form Console.Write( '*' ); Use a
                      statement of Console.WriteLi ne( ) to position to the next line; Use a
                      statement of Console.WriteLi ne( "" ) to display a space.
                      >
                      another option is e whoch ich exit the program; Any thing other than
                      a,b,c,e, will prompt error messagebox. I can do all that.
                      >
                      I just need logic how to go about the pattern.
                      I suspect (and hope) that no-one on the group will do your homework for
                      you. However, if you say exactly which part of the pattern logic you're
                      having problems with, how far you've got with it, and what code you've
                      already got, we may be able to help you.

                      --
                      Jon Skeet - <skeet@pobox.co m>
                      http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
                      If replying to the group, please do not mail me too

                      Comment

                      • Cor Ligthert [MVP]

                        #12
                        Re: How to do this?

                        :-)



                        Comment

                        • Ben Newsam

                          #13
                          Re: How to do this?

                          On 7 Oct 2006 22:30:31 -0700, "Amanda" <amanda772008@y ahoo.comwrote:
                          >Write a program that will allow user to choose to display traingles
                          >and diamonds composed of asterisks ina lopping condition?
                          Is this homework, by any chance?

                          --
                          Posted via a free Usenet account from http://www.teranews.com

                          Comment

                          • Ben Newsam

                            #14
                            Re: How to do this?

                            On 8 Oct 2006 00:04:33 -0700, "Amanda" <amanda772008@y ahoo.comwrote:
                            >I am auditing the class and I am trying to learn C# and in the process,
                            >are doing these assignments. Note that in my initial post, I
                            >said,"Sugges t me with logic". I didn't say write code for me but then
                            >your ego has blinded you such that you couldn't even read properly.
                            Statements such as the above won't help you get decent replies. The
                            way these things work is that people read posts (maybe scanning many
                            hundreds of them), they don't have time or inclination to read the
                            subtlest nuances in every syllable. If one particular posts catches
                            someone's interest enough, they will reply to it. They don't have to,
                            they could just pass on to the next one. Now, to me, "ego" is involved
                            when someone assumes that the whole world is hanging on ones every
                            word, rather than when people assume (rightly as it happens) that the
                            problem presented is in fact a classic homework assignment.

                            --
                            Posted via a free Usenet account from http://www.teranews.com

                            Comment

                            • Amanda

                              #15
                              Re: How to do this?


                              Ben Newsam wrote:
                              On 8 Oct 2006 00:04:33 -0700, "Amanda" <amanda772008@y ahoo.comwrote:
                              >
                              I am auditing the class and I am trying to learn C# and in the process,
                              are doing these assignments. Note that in my initial post, I
                              said,"Suggest me with logic". I didn't say write code for me but then
                              your ego has blinded you such that you couldn't even read properly.
                              >
                              Statements such as the above won't help you get decent replies.
                              So? The sky will fall down when the day arrives that I depend on others
                              to learn programming.

                              Btw, is there a groupie thing going on in this ng?

                              >The
                              way these things work is that people read posts (maybe scanning many
                              hundreds of them), they don't have time or inclination to read the
                              subtlest nuances in every syllable. If one particular posts catches
                              someone's interest enough, they will reply to it. They don't have to,
                              they could just pass on to the next one. Now, to me, "ego" is involved
                              when someone assumes that the whole world is hanging on ones every
                              word, rather than when people assume (rightly as it happens) that the
                              problem presented is in fact a classic homework assignment.
                              If it is so classic, why is it so diffucult for these egotistical ones
                              to give some tips like the one who did give?

                              When I was posting *initially*, I wasn't aware that the instructor
                              wanted us to use only one line of Console.Write(" *") and I was thinking
                              of putting *s in an array and hence my question.



                              >
                              --
                              Posted via a free Usenet account from http://www.teranews.com

                              Comment

                              Working...