4 Replies - 547 Views - Last Post: 29 April 2013 - 01:47 PM Rate Topic: -----

#1 Coregrader  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-April 13

Need help with homework project

Posted 29 April 2013 - 12:01 PM

Hello, I am new here and thank God I found you! I am having some trouble figuring out how to complete my homework. The project requires the following:
Create a form application which loops 10 times and prompts the user for a test score during each iteration of the loop using an InputBox object from the VB library
Drop the lowest score out of the 10 before averaging
Find the average of 9 scores
Create and use a class that you will call AvgMange with properties and methods that adhere to the Single Responsibility concept of method design
Create functionality to return the maximum score as well as the average

The problem is, I can't even figure out what I'm doing wrong with my loop. Here is what I have so far. Any input is much appreciated.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AverageScores
{
   public class AvgMange
    {
       
    
            private ListBox lstBox;
            public ListBox listBoxRef
            {
                set
                {
                    lstBox = value;
                    this.clearResults();
                }
            }
            public void clearResults()
            {
                lstBox.Items.Clear();
            }

            public void Averages(int Sums)
            {
                for (int I = 1; I <= 10; I++)
                {

                    if (I <= Sums)
                    {
                        lstBox.Items.Add(I);
                        Averages(Sums + I / I);
                        break;



                    }
                }
            }
        }
    }






Is This A Good Question/Topic? 0
  • +

Replies To: Need help with homework project

#2 tlhIn`toq  Icon User is offline

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

Reputation: 5480
  • View blog
  • Posts: 11,762
  • Joined: 02-June 10

Re: Need help with homework project

Posted 29 April 2013 - 12:14 PM

Quote

The problem is, I can't even figure out what I'm doing wrong with my loop.


This is homework, so we have very tight limits as to what we can do for you. Debugging is not one of them. And you haven't even described what is going wrong. We aren't going to copy your entire project into our own machines, run it, figure out the problem and then tell you how to fix it.

If you have an exception error for example, tell us and we will explain what the error means.


tlhIn`toq's FAQ list

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.


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 2013
Spoiler



Was This Post Helpful? 0
  • +
  • -

#3 Coregrader  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-April 13

Re: Need help with homework project

Posted 29 April 2013 - 01:36 PM

When I try to run the program I get an exception that says "Ensure you don't have an infinite loop or recursive." It points to the section of code where I try to add the result to lstBox. Sorry for the earlier misunderstanding. Thanks in advance for your help.

This post has been edited by tlhIn`toq: 29 April 2013 - 02:02 PM
Reason for edit:: No need to copy/paste the code: Its in the question.

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Need help with homework project

Posted 29 April 2013 - 01:38 PM

You do have recursion by virtue of calling Averages from within Averages.
Was This Post Helpful? 1
  • +
  • -

#5 Coregrader  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-April 13

Re: Need help with homework project

Posted 29 April 2013 - 01:47 PM

Oops. I feel dumb now. Thanks for the help! :hammer:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1