# Almost Done - Need Help

• 10-15-2008, 04:45 AM
Urgle
Almost Done - Need Help
I'm trying to teach myself how to program by looking for online project ideas. This one needs an average of 10 scores, also needs low score and high score.

Why does it say the min and max are the same? Here's my code:

import java.util.*;
import java.text.*;
{
public static void main ( String [ ] args )
{

Scanner scan = new Scanner( System.in);
DecimalFormat answer = new DecimalFormat( "#0.00");
int min = 0;
int max = 0;
double total = 0;

for( int i = 1; i <=10; i++)
{

{

{

}
{
}

}
}
double average = total / 10;
System.out.println( "The minimun value of your exam grades is " + min);
System.out.println( "The maximum value of your exam grades is " + max);

}
}
• 10-15-2008, 05:03 AM
Fubarable
Quote:

Originally Posted by Urgle
Why does it say the min and max are the same?

Because you tell them to be the same:
Code:

```      if (grade >= 0 && grade <= 100)       {         max = grade;         min = grade;```
To prevent this from happening, work out your strategy and algorithm on paper first before committing it to code.
• 10-16-2008, 02:55 AM
Urgle
ok, I figured that out, but ive been wondering how to find how many scores are above/below average. Ive tried everthing I can think of but its not working.
• 10-16-2008, 03:40 AM
emceenugget
Have you had the chance to work with arrays yet? You should play around with those, and I'm sure you'll figure out how to work it into your code.
• 10-16-2008, 03:53 AM
Fubarable
Quote:

Originally Posted by Urgle
ok, I figured that out, but ive been wondering how to find how many scores are above/below average. Ive tried everthing I can think of but its not working.

"its not working" tells us little. You will be much better served to show us your attempt at this and tell us specifically how it's not working out.

Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. You may want to click on the Preview Post button to make sure that your code is formatted correctly. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:

Code:

```&#91;code]   // your code block goes here.   // note the differences between the tag at the top vs the bottom. &#91;/code]```
Good luck.
• 10-16-2008, 06:06 AM
Eranga
First of all design a strong pattern to workout the problem. I'll give some tips, may be you can find something useful.

First collect all values and store them in an array from the user. So you need to learn about arrays. How to define, how to add and so on.

If you are stored them in an array, you can sort them. Once you sort all elements, first and last elements gives the required values. Easy to calculate total, average and so on.