Calculating The Modal Average Of An Array Of Numbers

Nov 6, 2010

OK, so I've been given an assignment due for Monday, which was to create a console program which allows the user to enter an unknown quantity of numbers, then have the Mean, Median and Mode averages displayed of said group of numbers.

So far I've managed to get the Mean and Median to work, for both odd and even quantities of variables. I am however stuck on getting it to calculate the modal average! I don't really know how to approach this, would a structure with two fields, variable and quantity of variable, work?

Below is the code, I haven't made it display discrete of continuous data yet, I'm leaving that for the end.

Module Module1
Sub Main()
Start:
'Declare Variables

[Code].....

I imagine this is quite elementary for most of you, I unfortunately received no replies what-so-ever to my last thread...

PS: Why isn't there an option for UK in the two letter country codes?

View 5 Replies


ADVERTISEMENT

Array Calculating Min, Max, And Average Output: Min, Max, And Average?

Mar 26, 2012

I put comments on the average output since I kept getting error messages about that. My out keeps saying:

Maximum value: 33
Minimum value: 33
what am I doing wrong?
Option Explicit On
Option Strict On

[Code]...

View 2 Replies

Calculating Exponential Average With Out A Simple Moving Average

Sep 8, 2009

I'm working on a function to return a exponential average and there are a lot of examples of exponential moving averages but they all start with a moving average that is just the mean as a lead in to calculating the continuing moving average. I needed just a exponential average of a value set. After Googling my Bing off I still haven't seen anything so here is my attempt at a basic exponential average. Is this correct? Are there any errors? I have seen some text about adding a smoothing value to change the curve of the exponential average but not how that would be implemented.

[Code]...

View 5 Replies

Calculating An Average From Input?

Feb 8, 2009

here is my problem. i have to enter two grades, each grade should be an integer between 0 and 100 inclusive. Calculate the average of the two grades. If the average is greater than or equal to 90, display "Grade is an A!". It goes down the line for "if average is _______, display " ______is a/n __!" I get the last part and I know how to figure an average...but i am not sure how to type it in code. He did an elseif example, but it wasn't with 2 numbers and didn't have to average anything. So I don't know how to write that code....is there anywhere to look to find it? Here is what I have so far.............

Module Module1
Sub Main()
Dim grade, sum, average As Double

[code].....

View 14 Replies

Calculating Average And Grade?

Jun 21, 2010

Using VB.NET write a program that can calculate the grade of a student based on his or her marks in five subjects as input according to the following rules:

Grade A: For average between 100 and 80 (inclusive)
Grade B: For average between 79 and 65 (inclusive)
Grade C: For average between 64 and 40 (inclusive)

[code].....

View 2 Replies

Calculating Student Average Using For Next

Oct 12, 2011

The idea of this program is to calculate and find total and average for 3 Students automatically. That is when the first data is entered and click on button the total and average of first student should be displayed in listbox. And we should be able to enter second data. Bu the problem is it is just printing the first average and total thrice.

Dim a As String
Dim tot, avg, N As Single
Dim I As Integer
For I = 1 To 3
tot = Val(TextBox2.Text) + Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text) + Val(TextBox6.Text)
[Code] .....

View 1 Replies

Calculating Button For Total And Average?

Apr 10, 2012

need to make sure I got everything right for my Calculate Button in displaying the Total and Average.

Option Explicit On
Option Strict On
Public Class Grades

[code]....

My problem is mostly in the Calculate Button, what is CStr? I already used that because I set my Explicit On and that suggested it. Also when I debug I enter my 3 grades and click calculate, 0 is displayed in both my Total and Average Label box.For the Average, how would I display it to 2 decimal places?How would I set a parameter for the exam scores to be between 0-100?Would it be Try/Catch? And where would I place that coding?How do I convert my textboxes to integers?

View 7 Replies

Calculating The Average Letters Per Word

Dec 10, 2009

Im having a problem getting my calculations to work. I need to find the average letters per word.

Private Sub btnCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCount.Click
'Determine word count and average letters / word in the sentence

[Code].....

View 2 Replies

Creating A Function For Calculating An Average?

Jun 28, 2011

I'm having a problem creating a function for calculating an average. I need to divide the sum of a column of integers by the number of rows in that column. These integers are generated by a datediff command and their values are assigned to textboxes in a report. The results can only be whole numbers, no decimal points.

I'm pretty new to this so if this is an obvious question please excuse my ignorance. If you need any more information to address my question please let me know.

View 4 Replies

Calculating An Average From Values Entered Into One Textbox

Feb 25, 2012

I am making this for a homework assignment and i need to calculate the average for values entered in textbox1 and place them in other textboxes. I dont understand how to do this with numbers all placed in the same spot. here is my code thus far:

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub

[Code].....

View 1 Replies

Calculating An Average Then Rounding To The Nearest Tenth?

Apr 1, 2011

I'm doing an assignment for class which is basically a simple program that takes 12 monthly temperatures and averages them. But I also need to round the average to the nearest tenth. I am not particularly good at programming or math and don't know how I would fit this into my code. I am Including My program thus far. I put in bold and italic where the calculation takes place.

Private Sub btnEmterTemperature_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmterTemperature.Click
'FOR BUTTON CLICK EVENT "ENTER TEMPERATURE"

[Code].....

View 2 Replies

Calculating The Rolling Average In Crystal Reports?

Jun 17, 2009

I'm trying to calculate the rolling average in a crystal report. I have got 4 weeks in a month, and I have calculated the average for each week so long. Now I want to calculate a rolling average. eg:

For week1: rolling average = (week1Average)/1
For week2: rolling average = (week1Average + week2Average)/2
For week3: rolling average = (week1Average + week2Average + week3Average)/3
etc.

The problem with the code below is that, it is not looping through,therefore the rolling average for each week is the same as its average value wich is not correct.

Dim i, weekNum as number
Dim tot as double
weekNum =Distinctcount({ItemRating.WeekNo})

[Code].....

View 1 Replies

Generic LINQ Extension For Calculating Weighted Average

May 14, 2012

I wrote the following generic LINQ extension for calculating weighted average in Visual Basic 2010:
<Extension()>
Function WeightedAverage(Of T)(ByVal source As IEnumerable(Of T),
ByVal selectorValue As Func(Of T, Integer),
ByVal selectorWeight As Func(Of T, Integer)) As Double
Dim weightedValueSum As Double
Dim weightSum As Integer
[Code] .....

How can I call this function as an Aggregate function of another LINQ query? I tried it in the following way:
Dim q1 = From jd In oContext.JobDatas
Where jd.Year = 2011
Select jd
Dim q2 = Aggregate num In q1 Into WeightedAverage(num.AvSalary, num.NumPosHolder)
The Visual Basic 2010 editor is telling me that the second query (q2) of the following code is not valid statement. On the comma between the first an second argument it's saying: ")" required.

View 1 Replies

Project - Average Numbers, Maximum And Minimum Values, Range Of The Numbers

Apr 7, 2009

Im trying to write a program that will do:

1.The average of the four numbers. This answer will be placed into a text box reserved for that value. This text box cannot be changed by the user.

2.The maximum and minimum values. These will be denoted by changing the color of the largest number green and the smallest number red.

3.The range of the numbers. The range is defined as the difference between the largest and smallest numbers. The range will be placed into its own text box, labeled as such. This text box cannot be changed by the user."

Im using visual studio 2008 and it has to be written in VB

View 35 Replies

Average Of Numbers In A List Box?

Feb 16, 2012

I am working on a project where i need to get the average of 6 numbers i enter in a ListBox. There is one ListBox, one button to get the average, and one label where the average is displayed. i need to use an array and I am using the Visual Basics Programming but i dont think it is that big of a difference.

View 5 Replies

Having To Average Three Numbers Setting Up?

Jul 12, 2009

I am having to average three numbers setting this up I need to use sub procedures. I cannot figure out what I am missing.

Public Class Main
Private Sub btnAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAverage.Click
Dim num1, num2, num3 As Double
Dim average As Double

[code]....

View 3 Replies

How To Average Greatest 3 Out Of 5 Numbers

Sep 26, 2009

I have a project and I need to record long jumps. I have 5 numbers but how do I average the greatest 3 of 5, I know how to average all 5. Also am I supposed to put Val for strings or not because only 0 shows up for when I put something in name but if I put a number it will show up a number

[Code]...

View 5 Replies

Calculating Numbers And Hours?

Mar 26, 2009

if i have two variables,

Dim Hours
Dim Minutes

what i want to do is add the minutes to hours, so if Hours =2, and minutes = 120 I want to say hours = hours+2, not so simple as it seems or am i missing something?

Dim hours
Dim mins
IF mins > 60

[code]....

View 2 Replies

Finding Average Of 2 Largest Numbers?

Feb 21, 2009

I am supposed to create a program that inputs 3 numbers, takes the two largest and outputs an average of those two numbers using simple ifelse statements and logical operators only. I can't seem to get it. I've messed around for a few hours now and nothing seems to be working.

Here's what I have:

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim score1 As Double

[Code].....

View 8 Replies

Finding Average Of Numbers In A List Box's?

May 4, 2010

Need to calculate Average Plan Duration for the 3 Shipment TypesSo far i haveQuote:

'CALCULATING AVERAGE DURATION FOR STANDARD
Dim iAverage As Integer
Dim iAvgDuration As Integer

[code]....

I uses the information from the list boxes, (lbShipmentDuration) and (lbShipmentMethod) to calcualte the average Duration for each Shipment Type.

View 19 Replies

Finding The Average Of A Set Of Numbers In A Listbox In VB?

Jun 20, 2012

I enter numbers and Names into a text box and click 'add to list'. THe names go into a seperate listbox to the numbers.I then press 'show me the list' and i get to view my numbers and names listed in the two listboxs. I also have a button which averages the numbers in the numbers list box. But i dont know how to get it to work I will divide by the number of items in the list box.note: The average will be displayed in a label called: lblavg

Here is a picture of my code: http:puu.sh/CsED
I have tried:
For each item In lstListAges.Selecteditems

[code]....

View 6 Replies

Use A Function To Calculate The Average Of Those Numbers?

Apr 28, 2011

I'm trying to write a program that allows the user to enter 10 numbers into an input box and then the program will use a function to calculate the average of those numbers. I'm really illiterate when it comes to Visual Basic.

View 2 Replies

Working On A Windows Forms App That Will Average A Set Of Numbers?

Jun 13, 2011

I'm working on a Windows forms app that will average a set of numbers, the only catch is that there are 10 textboxes(4 in the example for times sake), and not all of the textboxes could be filled with a number...I know that if i had a given set of numbers:

Dim a, b, c, d As Integer
a = t1.Text
b = t2.Text
c = t3.Text

[code].....

View 2 Replies

Calculating Weighted Probability (Random Numbers)

Feb 4, 2009

I am having a bit of difficulty figuring out a way to calculate the weighted probability (weighted "random" numbers) and apply it directly to the selection of a given line of a text file. In short, I wish to have a text file, where each line has it's own probability of being chosen (obviously not all would be the same). I wish the probability to be dynamic, and based off of thirds. As in, say I have 9 lines in a given text file, and I wish to weight the probability of the first three to be significantly higher than the 2/3 and the 3/3 portion of the text document.

Example:
Line 1 20%
Line 2 20%
Line 3 20%
Line 4 10%
Line 5 10%
Line 6 10%
Line 7 3.3%
Line 8 3.3%
Line 9 3.3%

With the above logic, first 1/3 of the lines = 60% sum total, middle 2/3 = sum total of 30%, and the last 3 are a sum total of 9.9% repeating. How would I go about achieving this dynamic assignment of probability, and choosing them randomly, based off of the given weight?

View 3 Replies

Series Of Numbers (separated By A Comma) And Find Average

Mar 11, 2010

I am new to VB and need to make a program that does the following:Write a VB.Net program that allows users to enter a series of numbers(separated by a comma) in a text box called series. When the users clicks the command button called Average, the program extracts the number one by one from the series and calculates the average, and outputs the average onto a textbox called Result.I understand how to get it to do the average, but how can I make the program count the numbers that I input and then divided by the sum? Also, how would i get it started.

View 2 Replies

VS 2008 : Code For An Average Of Numbers From 1 To A Number Entered?

Jan 8, 2012

i want to know the code for an average of numbers from 1 to a number entered?

View 31 Replies

VS 2008 Calculating Mode Of An Array/Specifics Of An Array?

Nov 17, 2009

I have an assignment, and one of the requirements are to take a list of colors in an array and determine which letter, of the first letters of every color in the array, appears the most. (Essentially the mode, if converted to numerical values).

View 7 Replies

Takes 3 Percentages(numbers) And Returns An Average Of The Grades In Letter Format(A,B,C)?

Apr 15, 2011

I'm new to coding and i need to make a program that takes 3 percentages(numbers) and returns an average of the grades in letter format(A,B,C). This is what I have so far:[code]......

View 2 Replies

Getting The Average Of An Array Using FOR NEXT?

Jun 21, 2012

i am trying to get the average of an array of numbers. There could be up to 999 indexes (I picked a large array because of the the numbers of entries the array could have). As you can see I have managed to get the program to calculate the Sum of the in the array, but I am struggling with getting the average.Say, for example, I enter three sets of 90's, I get 3. How do I get an average?(BTW I have programmed it so the numbers go into an List Box, so this is why you see no code to make up the array or to where the array is printing the values).

Dim Sum As Integer
Dim SumCount As Integer
Dim AverageCount As Integer

[code].....

View 7 Replies

Byte Array And Average Value

Jan 28, 2009

i'm working on something to get the average color from an image and the code i have puts all the rgb values into a byte array, so the values are being stored as (r,g,b,r,g,b,r,g,b,r,g,b,r,g,b,etc). how would i loop through each r value to add them to another array to then be able to calculate the average (and so forth for g and b as well).

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved