How to do this?

  • Thread starter Thread starter Amanda
  • Start date Start date
A

Amanda

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?
 
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 said:
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
 
This is online class. Difficult to ask instructor without saying' How
to do this?":)
 
Amanda said:
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.
 
Amanda said:
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. ;)
 
Jon,

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

Cor
 
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
 
Greg said:
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):

* ***** ***** *
** **** **** **
*** *** *** ***
**** ** ** ****
***** * * *****
 
Jon said:
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.
 
Cor said:
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.
 
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?
 
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.
 
Ben said:
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.
 
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 said:
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.
 
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.
 
Hi Amanda,

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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top