# Thread: Almost Done - Need Help

1. Member
Join Date
Oct 2008
Posts
30
Rep Power
0

## 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);

}
}

2. Originally Posted by Urgle
Why does it say the min and max are the same?
Because you tell them to be the same:
Java Code:
```      if (grade >= 0 && grade <= 100)
{
To prevent this from happening, work out your strategy and algorithm on paper first before committing it to code.

3. Member
Join Date
Oct 2008
Posts
30
Rep Power
0
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.

4. Senior Member
Join Date
Sep 2008
Posts
564
Rep Power
9
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.

5. 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:

Java Code:
```&#91;code]
// your code block goes here.
// note the differences between the tag at the top vs the bottom.
&#91;/code]```
Good luck.

6. 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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•