473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Student needs help

drg
My assignment is to have a user add scores to a listbox then write a
method to find the highest and lowest score in the list.

I am able to get and display the first index or the last index, or even
count the number of indexes, via foreach, if, while and for loops. I
can't seem to check each individual index against a common int to find
the highest or lowest.

I am using Visual C# Express edition 2005 and creating a Windows
Application.

I'm not asking for you to do my assignment I just need a hint, a clue --
something.

DRG

Aug 29 '07 #1
6 1571
Hi,

Where are you stuck?

"drg" <dr***@sbcglobal.netwrote in message
news:hn***************@newssvr17.news.prodigy.net. ..
My assignment is to have a user add scores to a listbox then write a
method to find the highest and lowest score in the list.

I am able to get and display the first index or the last index, or even
count the number of indexes, via foreach, if, while and for loops. I
can't seem to check each individual index against a common int to find the
highest or lowest.

I am using Visual C# Express edition 2005 and creating a Windows
Application.

I'm not asking for you to do my assignment I just need a hint, a clue --
something.

DRG

Aug 29 '07 #2
Is it the high and low score you are not able to get?

If so get a list of scores on a piece of paper and work out how You would
decide which is the lowest and highest number.... do it without thinking
about code, but work from the top of the list to the bottom.

come back if this is not enough of a hint....

Richard

"drg" <dr***@sbcglobal.netwrote in message
news:hn***************@newssvr17.news.prodigy.net. ..
My assignment is to have a user add scores to a listbox then write a
method to find the highest and lowest score in the list.

I am able to get and display the first index or the last index, or even
count the number of indexes, via foreach, if, while and for loops. I
can't seem to check each individual index against a common int to find the
highest or lowest.

I am using Visual C# Express edition 2005 and creating a Windows
Application.

I'm not asking for you to do my assignment I just need a hint, a clue --
something.

DRG

Aug 29 '07 #3

"drg" <dr***@sbcglobal.netwrote in message
news:hn***************@newssvr17.news.prodigy.net. ..
My assignment is to have a user add scores to a listbox then write a
method to find the highest and lowest score in the list.

I am able to get and display the first index or the last index, or even
count the number of indexes, via foreach, if, while and for loops. I
can't seem to check each individual index against a common int to find the
highest or lowest.

I am using Visual C# Express edition 2005 and creating a Windows
Application.

I'm not asking for you to do my assignment I just need a hint, a clue --
something.

I do this sort of thing by having a variable called "CurrentHighScore" or
something.
Set to zero to start off
Loop through your results, and if a score is higher than the current high
score, update the current high score.
At the end, the high score is the... er, high score.

Aug 29 '07 #4
Ya, use Jame's approach.
Start with two variables High, Low
Set High to be something like -1
and set Low to a number higher then any number you would have to deal
with.
Then for high, if a number is higher than High, make it the new high
number, same logic for low number.

Aug 29 '07 #5


"rhaazy" <rh****@gmail.comwrote in message
news:11*********************@57g2000hsv.googlegrou ps.com...
Ya, use Jame's approach.
Start with two variables High, Low
Set High to be something like -1
and set Low to a number higher then any number you would have to deal
with.
Then for high, if a number is higher than High, make it the new high
number, same logic for low number.
There are two constants that I would use instead of some arbitrary starting
numbers...

If you are using an 'int' value, I would use int.MaxValue for the starting
LOW number and int.MinValue for the starting HIGH number.

HTH,
Mythran
Aug 29 '07 #6
drg
Thanks for the help everyone. It seems that the line of code I was
missing was:

firstScore = int.Parse(lstScores.Items[scoreIndex].ToString());

without that I was not able to advance to the next index.

thanks again and as Arnold would say "I'll be back",

drg

drg wrote:
My assignment is to have a user add scores to a listbox then write a
method to find the highest and lowest score in the list.

I am able to get and display the first index or the last index, or even
count the number of indexes, via foreach, if, while and for loops. I
can't seem to check each individual index against a common int to find
the highest or lowest.

I am using Visual C# Express edition 2005 and creating a Windows
Application.

I'm not asking for you to do my assignment I just need a hint, a clue --
something.

DRG
Sep 2 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mojo | last post by:
Ok, I don't want to much help but I need a push. I am supposed to write a program with 3 classes: 1. Controlling class 2. Student class 3. Grades class Controlling class instantiates a student...
16
by: Kirk Bevins | last post by:
Hello, new to posting, got a dilema in c++. I cant seem to create new instances of my student class. The idea is to make a database where the user inputs surnames and library card numbers etc. The...
1
by: Student | last post by:
Hey I need to write an application that will scan my network, explicitly my network group. So it needs to do something like a "nbtscan" (you give it a parameter like 192.168.0.0/24 and it gives you...
1
by: GS | last post by:
I am looking for some software package for students information for school, is there any open-source package available?. This should collect complete student information like: student details,...
5
by: sandy | last post by:
I am a student with an assignement due tomorrow. I am to write a sort of a memory manager, I don't want to go into all of the details (it's long). I have the following header file for my memory...
2
by: sallyk07 | last post by:
Modify the Student class so that each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the...
11
by: xxbabysue123xx | last post by:
Heres the problem: Create a class Student with instance data name, studentNumber, class (where class is a String containing one of the following: “Freshman”, “Sophomore”, “Junior”, “Senior”. ...
3
by: smccloud | last post by:
Ok, I used to be a programming student but switched to networking. Unfortunately I do not remember a whole lot of programming (and can't find my old source code). I need to read a large file...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.