Help with Major Software Assignment (1 Viewer)

atschamp

New Member
Joined
Mar 17, 2004
Messages
15
Location
Grafton NSW
Gender
Undisclosed
HSC
N/A
Hi,

I'm currently doing the major software assignment which is due for me in about 3 weeks time. I need some help however finishing it as im pretty bad at software design lol....

My program is a maths tutoring program which was pretty simple. Most of the forms are just teaching children about maths etc but there are forms for Range, Mode, Mean and Median that have calculations in them..

I have managed to code the Range and Mean but need help with the Mode and Median (like i said im pretty stupid).

So if someone could offer some help and some suggestions of what more i could add to tie in with the program...

If anyone wants a copy of what i have so far its only about 150kb so just give me your email address and ill send it to you...im pretty desperate for help :)

Thanks
 

atschamp

New Member
Joined
Mar 17, 2004
Messages
15
Location
Grafton NSW
Gender
Undisclosed
HSC
N/A
... I forgot to add that we are using VISUAL BASIC 6 to complete our projects... anyone with VB6 experience ???? help me with these forms please :) lol
 

J0n

N/A
Joined
Aug 28, 2003
Messages
410
Gender
Male
HSC
2004
Are you storing your numbers in an array? If so, you can sort the array using one of the SDD standard sorting algorithms to sort the array, then you can find the middle element by using Ubound() and Lbound() (upper boundary and lower boundary of array).

Then, once you have a sorted array, you can just iterate through the array, and have one variable holding the current mode, one variable holding the number of times the mode has been present in the array, and one holding the number of times the current number has been in the array (since the array is sorted). Another way which would not require sorting would be to create another array, and effectively 'tally' up each of your numbers into the other array.
 
Last edited:

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
for mode, if you store everything in an array, you can use this module that i did for my assignment.

Code:
bool Majority(int A[MAX_SIZE], int F, int L, int& result)
{
int repetitionCounter = 0;     // temporary storage for the number of times a number is repeated
int maxRepetitionCounter = 0;     // stores the most number of repetions for a number

int halfOfArraySize = (L+1) / 2;      // half of the array's size, in terms of 'cells'
 
for (int loc = 0; loc <= L; loc++)    // loc is the 'focus' of the comparison for repetition
    {
     for(int i = (loc + 1); i <= L; i++)      // this loop enables the focus number to compare with the whole array, apart from itself
             {
             //cout << A[loc] << " compared to " << A[i]<<endl; // to check the 2 values being compared [for testing purpose]
              if (A[loc] == A[i])
                 {
                  repetitionCounter++;    // if match is found temp counter is incremented
                 }
             }
             if (repetitionCounter > maxRepetitionCounter)
                 {
                  maxRepetitionCounter = repetitionCounter;    // if a higher count for repetition is found it is saved
                  result = A[loc];
                 }
                 repetitionCounter = 1;           //coutner is reset
    }
  // you can ignore this if statement below...
if (maxRepetitionCounter > halfOfArraySize)
   {
    return true;
   }
else
   {
    return false;
   }
 
}
now it is obviously in c++, and NOT VB6, but i am hoping you get some of the syntax anyway...ask any questions, if you dont understand.

also i left the comments in there...they are the bits following the "//" to explain what happens.

edit: and for median you can just do a simple test...first check whether there are odd or even number of data [numbers].
if they are odd, then just find the n/2<sup>th</sup> cell in the array. you'll have to round that number off of course, but that would depend on how VB6 works.
if it is even, then find the n/2<sup>th</sup> and n/2+ 1<sup>th</sup> cell in the array and find their average.

edit2: for the median, you need to have your data sorted...so just do a sort[ bubble, insertion or selection]. there will be codes for that on many site ;)
 
Last edited:

atschamp

New Member
Joined
Mar 17, 2004
Messages
15
Location
Grafton NSW
Gender
Undisclosed
HSC
N/A
ah! ive tried to use the syntax etc from the C++ but i just cant get it. my project is due in the next 10 days now.. can anyone translate that for me into VB or just give me some more help
 

sladehk

le random
Joined
Jul 26, 2004
Messages
1,000
Gender
Undisclosed
HSC
2006
I'm not that into C++, just a beginner, but I can do the VB coding for you. Just send me your C++ project and what you want to do and I'll try to translate it for you.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
This thread is from 2 months ago. It was posted when the assignment was due 3 weeks away. Let this thread die.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top