473,486 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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?

Oct 8 '06 #1
41 1775
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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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?
Oct 8 '06 #2
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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
Oct 8 '06 #3
This is online class. Difficult to ask instructor without saying' How
to do this?":)
Peter Duniho wrote:
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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
Oct 8 '06 #4
Amanda <am**********@yahoo.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #5
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.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. ;)
Oct 8 '06 #6
Jon,

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

Cor

"Jon Skeet [C# MVP]" <sk***@pobox.comschreef in bericht
news:MP***********************@msnews.microsoft.co m...
Amanda <am**********@yahoo.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 8 '06 #7
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" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
This is online class. Difficult to ask instructor without saying' How
to do this?":)
Peter Duniho wrote:
>"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegr oups.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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

Oct 8 '06 #8

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.WriteLine();
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.WriteLine();
j++;
}
}
Now, I am trying the triagles showing side by side like this - I am
trying to show the first two):

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

>
Greg

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
This is online class. Difficult to ask instructor without saying' How
to do this?":)
Peter Duniho wrote:
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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
Oct 8 '06 #9

Jon wrote:
Amanda <am**********@yahoo.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #10

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]" <sk***@pobox.comschreef in bericht
news:MP***********************@msnews.microsoft.co m...
Amanda <am**********@yahoo.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.WriteLine( ) to position to the next line; Use a
statement of Console.WriteLine( "" ) 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #11
:-)

Oct 8 '06 #12
On 7 Oct 2006 22:30:31 -0700, "Amanda" <am**********@yahoo.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

Oct 8 '06 #13
On 8 Oct 2006 00:04:33 -0700, "Amanda" <am**********@yahoo.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. 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

Oct 8 '06 #14

Ben Newsam wrote:
On 8 Oct 2006 00:04:33 -0700, "Amanda" <am**********@yahoo.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
Oct 8 '06 #15
You loop is messy. My advise is your style is either < or <= and don't mess
them around.

Don't bother what reply you got. See, what you want is answer. So from here
what you can pick up is learning is never easy. If you really so interesting
in C# then go here:
http://msdn2.microsoft.com/en-us/vcsharp/default.aspx

Click on Learn C# and see what you have. Good luck.

chanmm

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
>
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.WriteLine();
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.WriteLine();
j++;
}
}
Now, I am trying the triagles showing side by side like this - I am
trying to show the first two):

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

>>
Greg

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googleg roups.com...
This is online class. Difficult to ask instructor without saying' How
to do this?":)
Peter Duniho wrote:
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegr oups.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.WriteLine( ) to position to the next line; Use
a
statement of Console.WriteLine( "" ) 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

Oct 8 '06 #16
Amanda <am**********@yahoo.comwrote:
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".
Where did you say "Suggest me with logic"? I didn't see anything saying
that.
I didn't say write code for me but then
your ego has blinded you such that you couldn't even read properly.
Shall we take a look at the first sentence of your first post?

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

How is that *not* asking people to write code for you?

As I said, if you could say how far you've got, and which particular
bit is giving you difficulty, you'll get a lot more positive replies
than you have done so far. If you're not willing to do that, and only
want to post insults, then you're unlikely to get help.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #17
On 8 Oct 2006 02:47:35 -0700, "Amanda" <am**********@yahoo.comwrote:
>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.
Using an array might work, but the reason the instructor wants you to
use Console.Write("*") is that he wants you to think about loops and
loops within loops. The code you posted shows that you have got the
general idea (but bear in mind the comments by chanmm). To get your
triangles side by side, you will have to think a bit harder about the
loops within loops involved, ie not just Triangle1 and Triangle2 as
you have written them.

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

Oct 8 '06 #18
Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
<snip>
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.
<snip>

Since there is apparently a lot of bad blood going on here, please allow me
to try and smooth things out, since I have no dog in this fight.

First, if you will re-read your initial post, you did *not* say "Suggest me
with logic". Below this reply I have posted the exact message, so that you
may review it. You simply gave a problem and requested "Write a program that
will ... ?" I will presume that English is not your native language, as the
syntax of your query is an imperative (command language) followed by a
question mark, which I will interpret as being more along the lines of "How
do I write a program that will...?".

It was in your *second* post that you added "I just need logic how to go
about the pattern." However, in neither of those posts did you explain why
you wanted this information, and it certainly did seem like a school
assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither Jon
nor Cor was at all sarcastic. In fact, having know Jon for quite awhile, I
can certainly tell you that his response had nothing to do with ego, but was
motivated by a sincere desire to help you. From time to time, students try
to use these newsgroups to get answers to homework questions, rather than
doing the work themselves. This only hurts them, as they do not learn what
is vital to their success as a programmer. Programming is difficult, and
involves problem-solving more than anything else. It is not the syntax of
programming that is difficult to learn; it is the problem-solving ability.
To help a student to do their homework by solving their problems for them
would be to cause them harm, and all of the experts agree on that point.
Here is the exact text of Jon's response:

******************* Jon's Response ************************
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.
************************************************** *****

He was not unkind, but offered counsel. In fact, he also offered to help
you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a student
that wanted someone to do their homework for them, the counsel was
appropriately designed to encourage the student to do the work required. The
additional offer of help was more than kind, under those circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a bit
of knowlege from experience here, which will certainly help you to learn
programming: Programming is also about logic. To assume that someone is
"blinded by their ego" without facts to support the assumption is to open
yourself to error. In programming, this sort of thinking will cause errors
in your programs. If you had simply explained your situation without making
false accusations, Jon would certainly have provided you with all the help
he could. In fact, I believe he is still willing to, but I can't speak for
him about that. He is very good at "turning the other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?
Oct 8 '06 #19
Kevin,

Sorry, I often compliment your with your messages, however first assuming
that English is not somebodies native language and that he is not able to
read or write that and than make such a long message is in my idea not
logical. You told programming is also about logic. I assume that you see
what I want to tell.

Therefore please leave that phase about native language from your messages,
it is needless injuring people. In this business in most cultures the
developers has only English as documentation. You are telling almost the
same as if they cannot do their jobs. In my idea is it not the goal in a
newsgroup to show how perfect you are in English but the content of your
message. (Which is mostly good from you by the way).

Cor
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:OG**************@TK2MSFTNGP03.phx.gbl...
Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
<snip>
>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.
<snip>

Since there is apparently a lot of bad blood going on here, please allow
me to try and smooth things out, since I have no dog in this fight.

First, if you will re-read your initial post, you did *not* say "Suggest
me with logic". Below this reply I have posted the exact message, so that
you may review it. You simply gave a problem and requested "Write a
program that will ... ?" I will presume that English is not your native
language, as the syntax of your query is an imperative (command language)
followed by a question mark, which I will interpret as being more along
the lines of "How do I write a program that will...?".

It was in your *second* post that you added "I just need logic how to go
about the pattern." However, in neither of those posts did you explain why
you wanted this information, and it certainly did seem like a school
assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither Jon
nor Cor was at all sarcastic. In fact, having know Jon for quite awhile, I
can certainly tell you that his response had nothing to do with ego, but
was motivated by a sincere desire to help you. From time to time, students
try to use these newsgroups to get answers to homework questions, rather
than doing the work themselves. This only hurts them, as they do not learn
what is vital to their success as a programmer. Programming is difficult,
and involves problem-solving more than anything else. It is not the syntax
of programming that is difficult to learn; it is the problem-solving
ability. To help a student to do their homework by solving their problems
for them would be to cause them harm, and all of the experts agree on that
point. Here is the exact text of Jon's response:

******************* Jon's Response ************************
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.
************************************************** *****

He was not unkind, but offered counsel. In fact, he also offered to help
you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a student
that wanted someone to do their homework for them, the counsel was
appropriately designed to encourage the student to do the work required.
The additional offer of help was more than kind, under those
circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a bit
of knowlege from experience here, which will certainly help you to learn
programming: Programming is also about logic. To assume that someone is
"blinded by their ego" without facts to support the assumption is to open
yourself to error. In programming, this sort of thinking will cause errors
in your programs. If you had simply explained your situation without
making false accusations, Jon would certainly have provided you with all
the help he could. In fact, I believe he is still willing to, but I can't
speak for him about that. He is very good at "turning the other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?


Oct 8 '06 #20

Ben Newsam wrote:
On 8 Oct 2006 02:47:35 -0700, "Amanda" <am**********@yahoo.comwrote:
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.

Using an array might work, but the reason the instructor wants you to
use Console.Write("*") is that he wants you to think about loops and
loops within loops.
Yes, I realized that. He should have stated CLEARLy that instruction
before displaying all triangles examples. I got those done last night
anyway.
The code you posted shows that you have got the
general idea (but bear in mind the comments by chanmm). To get your
triangles side by side, you will have to think a bit harder about the
loops within loops involved, ie not just Triangle1 and Triangle2 as
you have written them.
Yes, I had to think harder for that and got it. Thanks.

In your opinion, using arrays would defeat the purpose of this program,
i.e using for loops tin a way the instructor intended, wouldn't it?

>
--
Posted via a free Usenet account from http://www.teranews.com
Oct 8 '06 #21

Jon wrote:
Amanda <am**********@yahoo.comwrote:
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".

Where did you say "Suggest me with logic"? I didn't see anything saying
that.
Okay, okay. I said "Any guide?" Gimme a break, will you. I had flu,
you know?

I didn't say write code for me but then
your ego has blinded you such that you couldn't even read properly.

Shall we take a look at the first sentence of your first post?
If you wish but haven't i told you that I didn't see the instructor's
specific instructors later (in second post?
>
<quote>
Write a program that will allow user to choose to display traingles
and diamonds composed of asterisks ina lopping condition?
</quote>

How is that *not* asking people to write code for you?
See, I told you so. You didn't read things in context and hence you
didn't read properly.

>
As I said, if you could say how far you've got, and which particular
bit is giving you difficulty, you'll get a lot more positive replies
than you have done so far.
You are right but I was just getting started and was going to post my
code soon but you were too quick in using the lines "you want people to
do homework" or somwhtign like that as if I were a little kid.
If you're not willing to do that, and only
want to post insults, then you're unlikely to get help.
I wasn't insulting. I was merely pointing out how people judge each
other *SO* quickly and assume things. Beside, with the flu (nto too bad
yet but am worried that I will lose more time with this damn flu; I
ca't afford it), I wasn't really patient to explain the way I am doing
now. Anyway, have a good day.

>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #22

chanmm wrote:
You loop is messy. My advise is your style is either < or <= and don't mess
them around.

Don't bother what reply you got. See, what you want is answer. So from here
what you can pick up is learning is never easy. If you really so interesting
in C# then go here:
http://msdn2.microsoft.com/en-us/vcsharp/default.aspx

Click on Learn C# and see what you have. Good luck.
Thanks but I hate that kind of big pile of information where I have to
go through the maze where it will only show basic for loop exapmples
anyway.

Yes, learning is nott hat difficult at low level like now which I am
trying to become very efficient so that i can move onto advanced topics
quickly but time is a problem.

>
chanmm

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...

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.WriteLine();
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.WriteLine();
j++;
}
}
Now, I am trying the triagles showing side by side like this - I am
trying to show the first two):

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

>
Greg

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
This is online class. Difficult to ask instructor without saying' How
to do this?":)
Peter Duniho wrote:
"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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.WriteLine( ) to position to the next line; Use
a
statement of Console.WriteLine( "" ) 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
Oct 8 '06 #23

Kevin Spencer wrote:
Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
<snip>
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.
<snip>

Since there is apparently a lot of bad blood going on here,
Bad blood? It was more like fun to me. Just kidding:) Well, I forget
easily especially fights, and so Jon is forgiven for treating me like a
college kid:)
>please allow me
to try and smooth things out, since I have no dog in this fight.

First, if you will re-read your initial post, you did *not* say "Suggest me
with logic".
I did say "Any guide" and my intention was not to get the whole code
for the program. Anyone who wants that would be comunicatinfg witht
heir classmates, not here, don't you think?
>Below this reply I have posted the exact message, so that you
may review it. You simply gave a problem and requested "Write a program that
will ... ?" I will presume that English is not your native language, as the
syntax of your query is an imperative (command language) followed by a
question mark, which I will interpret as being more along the lines of "How
do I write a program that will...?".
Hey you are a genius. I didn't grow with English beyond knowing the
basic. And I hate typing.

Hey don't worry too much. I know that Jon assumed that I was a college
kid and trying to guide but I have a MS in Chemistry and am taking a
class so that I would be forced to do the work - I get sidtracked
otherwise - and learn C# syntax. Frankly, I don't like online class but
for C#, that's the only option at this school.
I read the rest of your posts and will respond that I didn't explain my
situation only because I had flu and didn't want to waste my energy
last night. I made the accusation about judging because of personal
reasons (beign treated like that by oldest sister) and I am definitely
sorry about that. And I was a bit rude in using the phrase "judging
with one's standard, ego, etc." That was my initial reaction because I
just hated being treated like a college kid or a kid period. I get that
from much older sisters all the time and all my misery in my whole
life comes from dealing with them.
I am trying to get better programming skills so that I can get a
programming job in medicinal chemistry environement. I need to stay
away form direct exposure to chemicals. Long story how I didn't know
about my nasal condition and got Chemistry degrees.

Good to know that Jon is good at "turning the other cheek."

To assume that someone is
"blinded by their ego" without facts to support the assumption is to open
yourself to error. In programming, this sort of thinking will cause errors
in your programs. If you had simply explained your situation without making
false accusations, Jon would certainly have provided you with all the help
he could. In fact, I believe he is still willing to, but I can't speak for
him about that. He is very good at "turning the other cheek."

>
It was in your *second* post that you added "I just need logic how to go
about the pattern." However, in neither of those posts did you explain why
you wanted this information, and it certainly did seem like a school
assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither Jon
nor Cor was at all sarcastic. In fact, having know Jon for quite awhile, I
can certainly tell you that his response had nothing to do with ego, but was
motivated by a sincere desire to help you.
>From time to time, students try
to use these newsgroups to get answers to homework questions, rather than
doing the work themselves. This only hurts them, as they do not learn what
is vital to their success as a programmer. Programming is difficult, and
involves problem-solving more than anything else. It is not the syntax of
programming that is difficult to learn; it is the problem-solving ability.
To help a student to do their homework by solving their problems for them
would be to cause them harm, and all of the experts agree on that point.
Here is the exact text of Jon's response:

******************* Jon's Response ************************
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.
************************************************** *****

He was not unkind, but offered counsel. In fact, he also offered to help
you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a student
that wanted someone to do their homework for them, the counsel was
appropriately designed to encourage the student to do the work required. The
additional offer of help was more than kind, under those circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a bit
of knowlege from experience here, which will certainly help you to learn
programming: Programming is also about logic. To assume that someone is
"blinded by their ego" without facts to support the assumption is to open
yourself to error. In programming, this sort of thinking will cause errors
in your programs. If you had simply explained your situation without making
false accusations, Jon would certainly have provided you with all the help
he could. In fact, I believe he is still willing to, but I can't speak for
him about that. He is very good at "turning the other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?
Oct 8 '06 #24

Jon

Will you accept my apology? If I didn't have flu, I would have typed
a bit more and explained.

Oct 8 '06 #25

Ben Newsam wrote:
On 7 Oct 2006 22:30:31 -0700, "Amanda" <am**********@yahoo.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?
It's an optional homework. Beside, I am not in need of a grade. If I
need a grade, I will be more agressive then this and get the code
somehow.

People, I am trying to learn, okay?
>
--
Posted via a free Usenet account from http://www.teranews.com
Oct 8 '06 #26
On 8 Oct 2006 09:17:41 -0700, "Amanda" <am**********@yahoo.comwrote:
>Yes, learning is nott hat difficult at low level like now which I am
trying to become very efficient so that i can move onto advanced topics
quickly but time is a problem.
Yes, but... you do need to put the time in to thinking about logical
problems such as the assignment you quote. It is, after all, a general
programming problem, not specifically about C# at all. Knowing how to
solve problems like that one[1] is a transferrable skill. There is no
real substitute for putting in the time and thinking about it.

[1] Ummm... not knowing how to solve it, exactly, more knowing how to
go about solving similar problems in a programming context.

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

Oct 8 '06 #27
Amanda <am**********@yahoo.comwrote:
Will you accept my apology? If I didn't have flu, I would have typed
a bit more and explained.
Yup, no problem. Now, did the answer from Ben solve everything for you?
If not, could you give more details about what exact part you're having
trouble with? If you could post the code as far as you've done it (even
if it has a lot of comments like "// Go round the loop here") that
would help a lot.

Just to make it clear: everyone here does want to help you learn. We
just have experience of a lot of people wanting quick answers instead
of taking the time to understand how things work. You'd be amazed at
how much time people will put into helping you once we're all pulling
in the same direction :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #28

Jon wrote:
Amanda <am**********@yahoo.comwrote:
Will you accept my apology? If I didn't have flu, I would have typed
a bit more and explained.

Yup, no problem.
Thanks.
>Now, did the answer from Ben solve everything for you?
I saw his post this morning. I got the trangles doen last night and
it's basically like what he said.

If not, could you give more details about what exact part you're having
trouble with? If you could post the code as far as you've done it (even
if it has a lot of comments like "// Go round the loop here") that
would help a lot.
Rihgt now I am working on the diamond. I am just doing w/o the option
of giving the user to enter an odd integer, like this:

public static void Diamond()
{
for (int i = 1, j = 0; i <9; i++)
{
for (int p = 8; p >=j; p--)
Console.Write(" ");
for (int p = 0; p <= j; p++)
Console.Write("*");
for (int p = 1; p <= j; p++)
Console.Write("*");
j++;
Console.WriteLine();
}

for (int i = 0, j = 0; i < 9; i++)
{
for (int c = 8; c >= j; c--)
Console.Write("*");
Console.WriteLine();
for (int p = 0; p <= j; p++)
Console.Write(" ");
for (int p = 9; p j; p--)
Console.Write("*");
j++;
}

I *need* to get rid of the ninth line in display (see below). May be I
should use a different logic and will definitely have to when I allow
the user to enter an odd number but until then, I want to solve the
curent issue.

*
***
*****
*******
*********
***********
*************
***************
*********
*****************
***************
*************
***********
*********
*******
*****
***
*
>
Just to make it clear: everyone here does want to help you learn. We
just have experience of a lot of people wanting quick answers instead
of taking the time to understand how things work. You'd be amazed at
how much time people will put into helping you once we're all pulling
in the same direction :)
I know. These comp.lang forums are amazing. Thanks.

>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #29

Ben Newsam wrote:
On 8 Oct 2006 09:17:41 -0700, "Amanda" <am**********@yahoo.comwrote:
Yes, learning is nott hat difficult at low level like now which I am
trying to become very efficient so that i can move onto advanced topics
quickly but time is a problem.

Yes, but... you do need to put the time in to thinking about logical
problems such as the assignment you quote. It is, after all, a general
programming problem, not specifically about C# at all.
I just meant that my goal was to know C# syntax but as far as
programming is concerned I was concentrating on Java - the industry I
want to get in is using Java mainly at the moment - but this C#
exercise is taking more time but that's ok. This type of logic is good
practise since it's a tranferrable skill, like you said. I do need to
get to SErvlets and JSP stuff ASAP soon after I becomes efficeint with
arrays, exception, file handling + I alos need to know Collection well.
I am in taking C# for syntax so that I can put it on resume.
>Knowing how to
solve problems like that one[1] is a transferrable skill.
>There is no
real substitute for putting in the time and thinking about it.
True.
>
[1] Ummm... not knowing how to solve it, exactly, more knowing how to
go about solving similar problems in a programming context.

--
Posted via a free Usenet account from http://www.teranews.com
Oct 8 '06 #30
Amanda <am**********@yahoo.comwrote:
If not, could you give more details about what exact part you're having
trouble with? If you could post the code as far as you've done it (even
if it has a lot of comments like "// Go round the loop here") that
would help a lot.

Rihgt now I am working on the diamond. I am just doing w/o the option
of giving the user to enter an odd integer, like this:

public static void Diamond()
{
for (int i = 1, j = 0; i <9; i++)
{
for (int p = 8; p >=j; p--)
Console.Write(" ");
for (int p = 0; p <= j; p++)
Console.Write("*");
for (int p = 1; p <= j; p++)
Console.Write("*");
j++;
Console.WriteLine();
}

for (int i = 0, j = 0; i < 9; i++)
{
for (int c = 8; c >= j; c--)
Console.Write("*");
Console.WriteLine();
for (int p = 0; p <= j; p++)
Console.Write(" ");
for (int p = 9; p j; p--)
Console.Write("*");
j++;
}
Okay. Before moving on to changing what the code does, I'm going to do
two things:

1) Put braces around *every* loop, even the inner ones.
2) Get rid of j.

To explain the second bit further:
In both of your loops, j is computable from i - in the first case,
j=i-1, in the second case j=i. It's very rare to see this sort of
double initialization in production code (at least in my experience)
partly because it makes it harder to understand. The whole goal of this
first stage is to change the code to make it easier to understand,
without changing the behaviour. The technical name for that activity is
*refactoring*.

So, here's your code after the above changes:

public static void Diamond()
{
for (int i = 1; i < 9; i++)
{
for (int p = 8; p >= (i-1); p--)
{
Console.Write(" ");
}
for (int p = 0; p <= (i-1); p++)
{
Console.Write("*");
}
for (int p = 1; p <= (i-1); p++)
{
Console.Write("*");
}
Console.WriteLine();
}

for (int i = 0; i < 9; i++)
{
for (int c = 8; c >= i; c--)
{
Console.Write("*");
}
Console.WriteLine();
for (int p = 0; p <= i; p++)
{
Console.Write(" ");
}
for (int p = 9; p i; p--)
{
Console.Write("*");
}
}
}

Now let's apply another refactoring suggested by chanmm: change every
inner loop to use <, and count upwards from 0:

public static void Diamond()
{
for (int i = 1; i < 9; i++)
{
for (int p = 0; p < 10-i; p++)
{
Console.Write(" ");
}
for (int p = 0; p < i; p++)
{
Console.Write("*");
}
for (int p = 0; p < i-1; p++)
{
Console.Write("*");
}
Console.WriteLine();
}

for (int i = 0; i < 9; i++)
{
for (int c = 0; c < 9-i; c++)
{
Console.Write("*");
}
Console.WriteLine();
for (int p = 0; p < i+1; p++)
{
Console.Write(" ");
}
for (int p = 0; p < 9-i; p++)
{
Console.Write("*");
}
}
}

Now the nice thing about those loops is that they're all writing either
spaces or stars, with the number of spaces or stars to write being the
right hand side of the middle expression. We'll now use the "extract
method" refactoring to make things simpler again, by having one method
to write stars and one to write spaces. (We could have a single method
which took a parameter which was the character to write, but that's
just a variation on the theme.)

public static void Diamond()
{
for (int i = 1; i < 9; i++)
{
WriteSpaces (10-i);
WriteStars (i);
WriteStars (i-1);
Console.WriteLine();
}

for (int i = 0; i < 9; i++)
{
WriteStars (9-i);
Console.WriteLine();
WriteSpaces(i+1);
WriteStars(9-i);
}
}

static void WriteStars(int count)
{
for (int i=0; i < count; i++)
{
Console.Write("*");
}
}

static void WriteSpaces(int count)
{
for (int i=0; i < count; i++)
{
Console.Write(" ");
}
}

Now, I'll pause there - partly because we've done an awful lot already,
and partly because I don't know whether you're allowed to use extra
methods in your code to make it more readable. Apologies if you've
already stated this in another post.

Now, as for the extra line - note that you're calling Console.WriteLine
at the *end* of each iteration of the first loop, but *in the middle*
of each iteration of the second loop. That should give you a hint as to
how to change the logic.

Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 8 '06 #31

Jon wrote:
[..]
Okay. Before moving on to changing what the code does, I'm going to do
two things:

1) Put braces around *every* loop, even the inner ones.
2) Get rid of j.

To explain the second bit further:
In both of your loops, j is computable from i - in the first case,
j=i-1, in the second case j=i. It's very rare to see this sort of
double initialization in production code (at least in my experience)
partly because it makes it harder to understand. The whole goal of this
first stage is to change the code to make it easier to understand,
without changing the behaviour. The technical name for that activity is
*refactoring*.
Ok.
>
So, here's your code after the above changes:
[]
>
Now let's apply another refactoring suggested by chanmm: change every
inner loop to use <, and count upwards from 0:
[]
>
Now the nice thing about those loops is that they're all writing either
spaces or stars, with the number of spaces or stars to write being the
right hand side of the middle expression. We'll now use the "extract
method" refactoring to make things simpler again, by having one method
to write stars and one to write spaces.
I plan to do that as a final step but the way I was looping would have
been a nightmare. Thanks for removing j and making all loops starts
from index 0.
>(We could have a single method
which took a parameter which was the character to write, but that's
just a variation on the theme.)

public static void Diamond()
{
for (int i = 1; i < 9; i++)
{
WriteSpaces (10-i);
WriteStars (i);
WriteStars (i-1);
Console.WriteLine();
}

for (int i = 0; i < 9; i++)
{
WriteStars (9-i);
Console.WriteLine();
WriteSpaces(i+1);
WriteStars(9-i);
}
}

static void WriteStars(int count)
{
for (int i=0; i < count; i++)
{
Console.Write("*");
}
}

static void WriteSpaces(int count)
{
for (int i=0; i < count; i++)
{
Console.Write(" ");
}
}

Now, I'll pause there - partly because we've done an awful lot already,
and partly because I don't know whether you're allowed to use extra
methods in your code to make it more readable. Apologies if you've
already stated this in another post.
He didn't say anything specifically on that. He gave his executable
file and we can look at the display as example. What extra method were
you thinking of?
>
Now, as for the extra line - note that you're calling Console.WriteLine
at the *end* of each iteration of the first loop, but *in the middle*
of each iteration of the second loop. That should give you a hint as to
how to change the logic.
Oh..I failed to look inside the for loop for the lower part of the
diamond shape.
>
Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.
Thanks. I now have a perfect diamond; the code would work with user's
choice of an odd integer too.

>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '06 #32
Hi Cor,

In this case, I suspected that some of the misunderstanding on the part of
the readers might have contributed to the problem. If you choose to
interpret my intention as otherwise, that is your choice. All I can say is
that it was my intention to be a peacemaker. Miscommunication occurs even
among people who speak the same language. We tend to hear what we want to
hear.

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uk**************@TK2MSFTNGP03.phx.gbl...
Kevin,

Sorry, I often compliment your with your messages, however first assuming
that English is not somebodies native language and that he is not able to
read or write that and than make such a long message is in my idea not
logical. You told programming is also about logic. I assume that you see
what I want to tell.

Therefore please leave that phase about native language from your
messages, it is needless injuring people. In this business in most
cultures the developers has only English as documentation. You are telling
almost the same as if they cannot do their jobs. In my idea is it not the
goal in a newsgroup to show how perfect you are in English but the content
of your message. (Which is mostly good from you by the way).

Cor
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:OG**************@TK2MSFTNGP03.phx.gbl...
>Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googlegro ups.com...
<snip>
>>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.
<snip>

Since there is apparently a lot of bad blood going on here, please allow
me to try and smooth things out, since I have no dog in this fight.

First, if you will re-read your initial post, you did *not* say "Suggest
me with logic". Below this reply I have posted the exact message, so that
you may review it. You simply gave a problem and requested "Write a
program that will ... ?" I will presume that English is not your native
language, as the syntax of your query is an imperative (command language)
followed by a question mark, which I will interpret as being more along
the lines of "How do I write a program that will...?".

It was in your *second* post that you added "I just need logic how to go
about the pattern." However, in neither of those posts did you explain
why you wanted this information, and it certainly did seem like a school
assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither Jon
nor Cor was at all sarcastic. In fact, having know Jon for quite awhile,
I can certainly tell you that his response had nothing to do with ego,
but was motivated by a sincere desire to help you. From time to time,
students try to use these newsgroups to get answers to homework
questions, rather than doing the work themselves. This only hurts them,
as they do not learn what is vital to their success as a programmer.
Programming is difficult, and involves problem-solving more than anything
else. It is not the syntax of programming that is difficult to learn; it
is the problem-solving ability. To help a student to do their homework by
solving their problems for them would be to cause them harm, and all of
the experts agree on that point. Here is the exact text of Jon's
response:

******************* Jon's Response ************************
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.
************************************************* ******

He was not unkind, but offered counsel. In fact, he also offered to help
you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a student
that wanted someone to do their homework for them, the counsel was
appropriately designed to encourage the student to do the work required.
The additional offer of help was more than kind, under those
circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a
bit of knowlege from experience here, which will certainly help you to
learn programming: Programming is also about logic. To assume that
someone is "blinded by their ego" without facts to support the assumption
is to open yourself to error. In programming, this sort of thinking will
cause errors in your programs. If you had simply explained your situation
without making false accusations, Jon would certainly have provided you
with all the help he could. In fact, I believe he is still willing to,
but I can't speak for him about that. He is very good at "turning the
other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?



Oct 9 '06 #33
Hi Amanda,

I'm glad I could help. And your response is certain to encourage people here
to help you whenever they can.

:-)

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
>
Kevin Spencer wrote:
>Hi Amanda,
<snip>
Hey don't worry too much. I know that Jon assumed that I was a college
kid and trying to guide but I have a MS in Chemistry and am taking a
class so that I would be forced to do the work - I get sidtracked
otherwise - and learn C# syntax. Frankly, I don't like online class but
for C#, that's the only option at this school.
<snip>
Oct 9 '06 #34
If I might make another observation about Jon's excellent discussion: This
process of refactoring is an excellent way to solve a problem. Quite often,
it is difficult to write the most elegant, or the most optimal code in the
beginning. A good developer will often begin by writing out a long solution,
what I like to call "bludgeoning your way through" the problem, ignoring the
optimizations in the beginning. Once the first draft of the code is done,
one can look it over for sections that can be refactored, repeated code that
can be made into loops or functions, and other optimizations. As Jon
illustrated, the re-analysis and refactoring process can be repeated, as
each new configuration of the code tends to suggest its own optimizations.
This process generally ends up taking less time than attempting to write the
leanest code on the first run.

And of course, for someone who is learning (as we all are, I would hope),
the most important goal is realized first, which is writing code that does
the job. As you progress with your skill and practice, you will be able to
spot more and more ways of making it leaner, more reusable (writing methods
and classes that perform common tasks), and more extensible.

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Amanda <am**********@yahoo.comwrote:
<snip>
Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.

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

Oct 9 '06 #35
Kevin,

I had not any doubt that your intentions were as you wrote, I only ask you
to leave the phrases about the knowledge of English out of your messages.
You would once go to England, than you can see how English is completely
different used inside 100 miles. If you go to Great Brittain, you will
probably be even more suprised (Although all inhabitants of Great Brittain
understand each other mostly perfectly)

Cor

"Kevin Spencer" <sp**@uce.govschreef in bericht
news:OK**************@TK2MSFTNGP04.phx.gbl...
Hi Cor,

In this case, I suspected that some of the misunderstanding on the part of
the readers might have contributed to the problem. If you choose to
interpret my intention as otherwise, that is your choice. All I can say is
that it was my intention to be a peacemaker. Miscommunication occurs even
among people who speak the same language. We tend to hear what we want to
hear.

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uk**************@TK2MSFTNGP03.phx.gbl...
>Kevin,

Sorry, I often compliment your with your messages, however first assuming
that English is not somebodies native language and that he is not able to
read or write that and than make such a long message is in my idea not
logical. You told programming is also about logic. I assume that you see
what I want to tell.

Therefore please leave that phase about native language from your
messages, it is needless injuring people. In this business in most
cultures the developers has only English as documentation. You are
telling almost the same as if they cannot do their jobs. In my idea is it
not the goal in a newsgroup to show how perfect you are in English but
the content of your message. (Which is mostly good from you by the way).

Cor
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:OG**************@TK2MSFTNGP03.phx.gbl...
>>Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googlegr oups.com...
<snip>
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.
<snip>

Since there is apparently a lot of bad blood going on here, please allow
me to try and smooth things out, since I have no dog in this fight.

First, if you will re-read your initial post, you did *not* say "Suggest
me with logic". Below this reply I have posted the exact message, so
that you may review it. You simply gave a problem and requested "Write a
program that will ... ?" I will presume that English is not your native
language, as the syntax of your query is an imperative (command
language) followed by a question mark, which I will interpret as being
more along the lines of "How do I write a program that will...?".

It was in your *second* post that you added "I just need logic how to go
about the pattern." However, in neither of those posts did you explain
why you wanted this information, and it certainly did seem like a school
assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither
Jon nor Cor was at all sarcastic. In fact, having know Jon for quite
awhile, I can certainly tell you that his response had nothing to do
with ego, but was motivated by a sincere desire to help you. From time
to time, students try to use these newsgroups to get answers to homework
questions, rather than doing the work themselves. This only hurts them,
as they do not learn what is vital to their success as a programmer.
Programming is difficult, and involves problem-solving more than
anything else. It is not the syntax of programming that is difficult to
learn; it is the problem-solving ability. To help a student to do their
homework by solving their problems for them would be to cause them harm,
and all of the experts agree on that point. Here is the exact text of
Jon's response:

******************* Jon's Response ************************
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.
************************************************ *******

He was not unkind, but offered counsel. In fact, he also offered to help
you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a
student that wanted someone to do their homework for them, the counsel
was appropriately designed to encourage the student to do the work
required. The additional offer of help was more than kind, under those
circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a
bit of knowlege from experience here, which will certainly help you to
learn programming: Programming is also about logic. To assume that
someone is "blinded by their ego" without facts to support the
assumption is to open yourself to error. In programming, this sort of
thinking will cause errors in your programs. If you had simply explained
your situation without making false accusations, Jon would certainly
have provided you with all the help he could. In fact, I believe he is
still willing to, but I can't speak for him about that. He is very good
at "turning the other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?




Oct 9 '06 #36
Amanda <am**********@yahoo.comwrote:

<snip>
Now, I'll pause there - partly because we've done an awful lot already,
and partly because I don't know whether you're allowed to use extra
methods in your code to make it more readable. Apologies if you've
already stated this in another post.

He didn't say anything specifically on that. He gave his executable
file and we can look at the display as example. What extra method were
you thinking of?
The WriteStars and WriteSpaces ones I added.
Now, as for the extra line - note that you're calling Console.WriteLine
at the *end* of each iteration of the first loop, but *in the middle*
of each iteration of the second loop. That should give you a hint as to
how to change the logic.

Oh..I failed to look inside the for loop for the lower part of the
diamond shape.
Just as an idea for if that kind of thing happens again, one of the
things I'd probably have done in your situation is put:
Console.WriteLine ("Finished first loop");

between the two big loops. That would make it clear which part was
going wrong. Easy to say in retrospect though :)
Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.

Thanks. I now have a perfect diamond; the code would work with user's
choice of an odd integer too.
Cool :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '06 #37

Jon wrote:
Amanda <am**********@yahoo.comwrote:

<snip>
Now, I'll pause there - partly because we've done an awful lot already,
and partly because I don't know whether you're allowed to use extra
methods in your code to make it more readable. Apologies if you've
already stated this in another post.
He didn't say anything specifically on that. He gave his executable
file and we can look at the display as example. What extra method were
you thinking of?

The WriteStars and WriteSpaces ones I added.
That should be ok. I was calling Traingles1(), Triangles2(), etc. in
DisplayTrianglesOneBelowAnother().

>
Now, as for the extra line - note that you're calling Console.WriteLine
at the *end* of each iteration of the first loop, but *in the middle*
of each iteration of the second loop. That should give you a hint as to
how to change the logic.
Oh..I failed to look inside the for loop for the lower part of the
diamond shape.

Just as an idea for if that kind of thing happens again, one of the
things I'd probably have done in your situation is put:
Console.WriteLine ("Finished first loop");

between the two big loops. That would make it clear which part was
going wrong.
Yeah, I need to develope the habit of doing that.
>Easy to say in retrospect though :)
Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.
Thanks. I now have a perfect diamond; the code would work with user's
choice of an odd integer too.

Cool :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '06 #38

Kevin Spencer wrote:
If I might make another observation about Jon's excellent discussion: This
process of refactoring is an excellent way to solve a problem. Quite often,
it is difficult to write the most elegant, or the most optimal code in the
beginning. A good developer will often begin by writing out a long solution,
what I like to call "bludgeoning your way through" the problem, ignoring the
optimizations in the beginning. Once the first draft of the code is done,
one can look it over for sections that can be refactored, repeated code that
can be made into loops or functions, and other optimizations. As Jon
illustrated, the re-analysis and refactoring process can be repeated, as
each new configuration of the code tends to suggest its own optimizations.
This process generally ends up taking less time than attempting to write the
leanest code on the first run.

And of course, for someone who is learning (as we all are, I would hope),
the most important goal is realized first, which is writing code that does
the job. As you progress with your skill and practice, you will be able to
spot more and more ways of making it leaner, more reusable (writing methods
and classes that perform common tasks), and more extensible.
Yes, these days I am a bit more aware of that (and will try to do that)
than when I was just learning programming. At that time, I barely had
enough time to meet deadline ( taking for grade at the time) and so
once I finished it, I didn't have the luxury to go back and optimize
it.

>
--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Amanda <am**********@yahoo.comwrote:
<snip>
Do let us know how you get on with the above - and if any of it doesn't
make sense, please say and I'll go back and explain in more detail.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 9 '06 #39
On Mon, 9 Oct 2006 05:54:26 +0200, "Cor Ligthert [MVP]"
<no************@planet.nlwrote:
>I had not any doubt that your intentions were as you wrote, I only ask you
to leave the phrases about the knowledge of English out of your messages.
You would once go to England, than you can see how English is completely
different used inside 100 miles. If you go to Great Brittain, you will
probably be even more suprised (Although all inhabitants of Great Brittain
understand each other mostly perfectly)
Och aye! 'Appen! Awight?

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

Oct 9 '06 #40
Sorry, Cor, but I must follow my conscience. Feel free to follow your own.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uC**************@TK2MSFTNGP04.phx.gbl...
Kevin,

I had not any doubt that your intentions were as you wrote, I only ask you
to leave the phrases about the knowledge of English out of your messages.
You would once go to England, than you can see how English is completely
different used inside 100 miles. If you go to Great Brittain, you will
probably be even more suprised (Although all inhabitants of Great Brittain
understand each other mostly perfectly)

Cor

"Kevin Spencer" <sp**@uce.govschreef in bericht
news:OK**************@TK2MSFTNGP04.phx.gbl...
>Hi Cor,

In this case, I suspected that some of the misunderstanding on the part
of the readers might have contributed to the problem. If you choose to
interpret my intention as otherwise, that is your choice. All I can say
is that it was my intention to be a peacemaker. Miscommunication occurs
even among people who speak the same language. We tend to hear what we
want to hear.

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uk**************@TK2MSFTNGP03.phx.gbl...
>>Kevin,

Sorry, I often compliment your with your messages, however first
assuming that English is not somebodies native language and that he is
not able to read or write that and than make such a long message is in
my idea not logical. You told programming is also about logic. I assume
that you see what I want to tell.

Therefore please leave that phase about native language from your
messages, it is needless injuring people. In this business in most
cultures the developers has only English as documentation. You are
telling almost the same as if they cannot do their jobs. In my idea is
it not the goal in a newsgroup to show how perfect you are in English
but the content of your message. (Which is mostly good from you by the
way).

Cor
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:OG**************@TK2MSFTNGP03.phx.gbl...
Hi Amanda,

"Amanda" <am**********@yahoo.comwrote in message
news:11*********************@e3g2000cwe.googleg roups.com...
<snip>
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.
<snip>

Since there is apparently a lot of bad blood going on here, please
allow me to try and smooth things out, since I have no dog in this
fight.

First, if you will re-read your initial post, you did *not* say
"Suggest me with logic". Below this reply I have posted the exact
message, so that you may review it. You simply gave a problem and
requested "Write a program that will ... ?" I will presume that English
is not your native language, as the syntax of your query is an
imperative (command language) followed by a question mark, which I will
interpret as being more along the lines of "How do I write a program
that will...?".

It was in your *second* post that you added "I just need logic how to
go about the pattern." However, in neither of those posts did you
explain why you wanted this information, and it certainly did seem like
a school assignment.

Now, there were 1 or 2 sarcastic responses to your query, but neither
Jon nor Cor was at all sarcastic. In fact, having know Jon for quite
awhile, I can certainly tell you that his response had nothing to do
with ego, but was motivated by a sincere desire to help you. From time
to time, students try to use these newsgroups to get answers to
homework questions, rather than doing the work themselves. This only
hurts them, as they do not learn what is vital to their success as a
programmer. Programming is difficult, and involves problem-solving more
than anything else. It is not the syntax of programming that is
difficult to learn; it is the problem-solving ability. To help a
student to do their homework by solving their problems for them would
be to cause them harm, and all of the experts agree on that point. Here
is the exact text of Jon's response:

******************* Jon's Response ************************
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.
*********************************************** ********

He was not unkind, but offered counsel. In fact, he also offered to
help you, if you would provide the information he requested. Under the
circumstances, with your message for all the world looking like a
student that wanted someone to do their homework for them, the counsel
was appropriately designed to encourage the student to do the work
required. The additional offer of help was more than kind, under those
circumstances.

So, we apparently have a misunderstanding here. Perhaps you can take a
bit of knowlege from experience here, which will certainly help you to
learn programming: Programming is also about logic. To assume that
someone is "blinded by their ego" without facts to support the
assumption is to open yourself to error. In programming, this sort of
thinking will cause errors in your programs. If you had simply
explained your situation without making false accusations, Jon would
certainly have provided you with all the help he could. In fact, I
believe he is still willing to, but I can't speak for him about that.
He is very good at "turning the other cheek."

--
HTH,

Kevin Spencer
Microsoft MVP
Computer Control Freak
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

******************* Original Post **************************
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?




Oct 9 '06 #41
I was trying to do the first the problem (problem a) in a single.
Amanda <amanda772...@yahoo.comwrote:
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:
*
**
***
****
*****
*****
****
***
**

I could do that in the following way.

class puzzles
{
private const int height = 100;
private const int flipPoint = 5;
public static void DrawDiamondTriangle()
{
const int CountChars = 102;
const int FlipPoint = 5;
int Counter = 0;
int CharPerLine = 1;
int tempcounter =0;
bool isDescending = false;
int flipCount = 0;
while (Counter < CountChars)
{

Console.Write("*");
Counter++;
if ((Counter - CharPerLine) == tempcounter)
{
flipCount++;
if (flipCount == FlipPoint)
{
isDescending = !isDescending;
flipCount = 1;
}
Console.WriteLine("");
if (isDescending)
CharPerLine--;
else
CharPerLine++;
tempcounter = Counter;

}

}
}
*

Oct 10 '06 #42

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3328
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
2735
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
2708
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
2527
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
3256
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
3187
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
10032
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
6
2648
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE...
1
2182
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
3133
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.