# Im having trouble with this problem please help.

Page 1 of 1

## 6 Replies - 805 Views - Last Post: 18 April 2012 - 07:48 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=275807&amp;s=7fb59180cd680e6407cb24770246cc4a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 mskiki14

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 18-April 12

# Im having trouble with this problem please help.

Posted 18 April 2012 - 05:40 PM

create a 2D array that holds grades 6 courses for 20 students. Generate random grades. compute the average for each student. compute the average for each course. Display all grades and averages in a table. What am i doing wrong?
```class Program
{
static void Main(string[] args)
{
Random rand = new Random;
int [,] grades = new int [6,20];
for (int x = 0; x < grades.GetLength (0); ++x)
{
for (int y = 0; y < grades.GetLength (1); ++y);
{
grades [x, y] = 70 + rand.Next () % 31;
}
}

int [] Average = new int [20];
Console.WriteLine("Grade summary: r\n\");
Console.WriteLine("Student  1  2  3  4  5  6  7  8");
Console.WriteLine("------------------------------------------------------------------------")

for (int x = 0; x < grades .GetLength  (0); ++x)
{
Console.Write("Math" + (x +1) + " ");
for (int y = 0; y < grades .GetLength(1); ++y)
{
Average [y] += grades [x, y];
Console.write("{0, 4: D}", grades [x, y]);
}
Console.WriteLine();

}
Console.Write("\r\n avg. ");
foreach (int avg in Average)
{
Console.Write("{0,4:D}", Average / grades.GetLength (0));
}
Console.WriteLine();
}
}
}

```

Is This A Good Question/Topic? 0

## Replies To: Im having trouble with this problem please help.

### #2 tlhIn`toq

• Please show what you have already tried when asking a question.

Reputation: 5862
• Posts: 12,769
• Joined: 02-June 10

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 05:48 PM

There are more than 500,000 users on the DIC. Can you imagine if they all started threads as "Problem" ? Please use meaningful titles so the people with the most knowledge in your area are drawn to your question. This also helps people later using search engines to find they help they need.

Quote

What am i doing wrong?

What problems are you having? We're not telepathic. You have to actually tell us what's happening on your end, and how it is different than what you expected... error messages... Crashing... Wrong results...
Was This Post Helpful? 0

### #3 eclipsed4utoo

• Not Your Ordinary Programmer

Reputation: 1527
• Posts: 5,963
• Joined: 21-March 08

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 06:11 PM

And to add to what tlhIn`toq posted, we are not here to do your homework. We are happy to help you get past problems you are having, but we will not give you the code. You need to tell us what your problem is.
Was This Post Helpful? 0

### #4 mskiki14

• New D.I.C Head

Reputation: 0
• Posts: 3
• Joined: 18-April 12

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 06:55 PM

Well I'll tell you what's happening on my end it won't run! Does that clarify things for you?
Was This Post Helpful? 0

### #5 Curtis Rutland

• （╯°□°）╯︵ (~ .o.)~

Reputation: 4641
• Posts: 8,197
• Joined: 08-June 10

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 07:14 PM

Not in the slightest. We're not being mean or anything...you have to give to get. You have to tell us specifically what's happening, as in...does it crash? Does it run? Does it give you any output? Is the output different than what you want? How's it different? If there's an exception, what's the line number? What's the exception text?

See what we're getting at here?
Was This Post Helpful? 0

### #6 tlhIn`toq

• Please show what you have already tried when asking a question.

Reputation: 5862
• Posts: 12,769
• Joined: 02-June 10

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 07:41 PM

mskiki14, on 18 April 2012 - 07:55 PM, said:

Well I'll tell you what's happening on my end it won't run! Does that clarify things for you?

It clarifies that your attitude towards those you are asking for help isn't the greatest, and falling dangerously close to this article. You're tired. You're frustrated. I get that. But remember, you're not frustrated WITH US. So don't take it out on us.

Next: Visual Studio is showing you and telling you of all the things you need to fix. So look and fix them.
Do you see all the red lines under parts of your code: Those are problems. If you hover over them it will TELL you what's wrong with them.

And there is a list at the bottom if you try to compile.

mskiki14: What this shows us is that you aren't familiar with breakpoints and how to debug your own code. Learning to debug one's own code is an essential skill. Sadly, one that apparently few college courses teach. Silly if you ask me.

Placing breakpoints and walking through the code line by line allows you to actually WATCH it execute.

Visualizing what your code does will let you see why it behaves the way it does.

It would be well worth your time to do the tutorials on FAQ 2. A couple hours learning this skill will save you hundreds of hours of confusion in one project alone.

See FAQ # 2. (Click the SHOW button below)

TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2

FAQ (Frequently Asked Questions - Updated Apr 2012
Spoiler

Was This Post Helpful? 0

### #7 tlhIn`toq

• Please show what you have already tried when asking a question.

Reputation: 5862
• Posts: 12,769
• Joined: 02-June 10

## Re: Im having trouble with this problem please help.

Posted 18 April 2012 - 07:48 PM

just to get you going on one of your bugs...

You have to pay attention to the examples in your textbook...
Its not r\n\"
That reads as r{escape n}{escape quote}
You want {escape r}{escape n} quote so \r\n"
That would be {return}{NewLine} end-quote

The compiler will give you what you tell it, not what you meant. Details are important.
Was This Post Helpful? 1

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }